Initial commit
This commit is contained in:
commit
352fa38ef3
8 files changed
+207
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { Radarr, Deluge, sleep } from './helpers.js';
|
||||
|
||||
const radarrEventtype = process.env.radarr_eventtype;
|
||||
const radarrUrl = process.env.RADARR_URL;
|
||||
const radarrApiKey = process.env.RADARR_API_KEY;
|
||||
const radarrMovieId = process.env.radarr_movie_id
|
||||
const radarrDownloadId = process.env.radarr_download_id
|
||||
const delugeUrl = process.env.DELUGE_URL;
|
||||
const delugeKey = process.env.DELUGE_PASS;
|
||||
|
||||
async function main() {
|
||||
if (radarrEventtype !== 'Grab') {
|
||||
console.log('Event type is not Grab, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
const radarr = new Radarr(radarrUrl, radarrApiKey);
|
||||
const radarrMovie = await radarr.getMovie(radarrMovieId);
|
||||
|
||||
const deluge = new Deluge(delugeUrl);
|
||||
await deluge.login(delugeKey);
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const torrentStatus = await deluge.getTorrentStatus(radarrDownloadId.toLowerCase());
|
||||
|
||||
if (!torrentStatus.result?.download_location) {
|
||||
// Torrent not found, wait and try again
|
||||
await sleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (torrentStatus.result.tracker_host === "linkomanija.org") {
|
||||
await deluge.setTorrentLabel(radarrDownloadId.toLowerCase(), "linkomanija");
|
||||
}
|
||||
|
||||
if (torrentStatus.result.download_location !== radarrMovie.path) {
|
||||
const moveStorage = await deluge.moveTorrent(radarrDownloadId.toLowerCase(), radarrMovie.path);
|
||||
console.log('Moved torrent to', radarrMovie.path);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
Reference in new issue
Block a user