Skip to content

Commit

Permalink
Add config template
Browse files Browse the repository at this point in the history
  • Loading branch information
mmgoodnow committed Jun 11, 2020
1 parent 5276503 commit 286b007
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ dist

*.torrent
torrents/
config.js
15 changes: 15 additions & 0 deletions config.template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
module.exports = {
jackettServerUrl: "http://localhost:9117/jackett",
jackettApiKey: "YOUR_JACKETT_API_KEY_HERE",

// Pause at least this much in between each Jackett search. Higher is safer.
// It is not recommended to set this to less than 2 seconds.
delayMs: 10 * 1000,

// Tracker to search. As of right now, can be one of:
// - the string "all"
// - a single tracker id as found in its Torznab feed
// e.g. "oink"
trackers: "all",

// directory containing torrent files.
// For rtorrent, this is your session directory
// as configured in your .rtorrent.rc file.
// For deluge, this is ~/.config/deluge/state.
torrentDir: "/path/to/torrent/file/dir",
};
22 changes: 2 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const util = require("util");
const querystring = require("querystring");

const axios = require("axios");
const minimist = require("minimist");
const chalk = require("chalk");

const config = require("config");

const EPISODE_REGEX = /S\d\dE\d\d/i;
const jackettPath = "/api/v2.0/indexers/all/results";

Expand All @@ -22,25 +23,6 @@ let offset = 0;

const parseTorrentRemote = util.promisify(parseTorrent.remote);

function parseCommandLineArgs() {
const options = minimist(process.argv.slice(2));

if (!options._[0]) console.error("specify a directory containing torrents");
if (!options.o) console.error("specify an output directory with -o");
if (!options.u) console.error("specify jackett url with -u");
if (!options.k) console.error("specify jackett api key with -k");
if (!(options.k && options.u && options.o && options._[0])) return false;

jackettServerUrl = options.u;
jackettApiKey = options.k;
torrentDir = options._[0];
outputDir = options.o;
offset = options.s || offset;
delay = (options.d || 10) * 1000;

return true;
}

function makeJackettRequest(query) {
const params = querystring.stringify({
apikey: jackettApiKey,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"axios": "^0.19.2",
"bencode": "^2.0.1",
"chalk": "^4.1.0",
"minimist": "^1.2.5",
"commander": "^5.1.0",
"parse-torrent": "^7.1.3"
},
"type": "module",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

commander@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==

debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
Expand Down Expand Up @@ -98,11 +103,6 @@ mimic-response@^2.0.0:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43"
integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==

minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down

0 comments on commit 286b007

Please sign in to comment.