cross-seed 7.0.0-1 → 7.0.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Result.d.ts +27 -0
- package/dist/Result.js +64 -0
- package/dist/Result.js.map +1 -0
- package/dist/action.d.ts +34 -0
- package/dist/action.js +694 -0
- package/dist/action.js.map +1 -0
- package/dist/arr.d.ts +31 -0
- package/dist/arr.js +267 -0
- package/dist/arr.js.map +1 -0
- package/dist/auth.d.ts +3 -0
- package/dist/auth.js +28 -0
- package/dist/auth.js.map +1 -0
- package/dist/clients/Deluge.d.ts +153 -0
- package/dist/clients/Deluge.js +698 -0
- package/dist/clients/Deluge.js.map +1 -0
- package/dist/clients/QBittorrent.d.ts +218 -0
- package/dist/clients/QBittorrent.js +785 -0
- package/dist/clients/QBittorrent.js.map +1 -0
- package/dist/clients/RTorrent.d.ts +43 -0
- package/dist/clients/RTorrent.js +657 -0
- package/dist/clients/RTorrent.js.map +1 -0
- package/dist/clients/TorrentClient.d.ts +108 -0
- package/dist/clients/TorrentClient.js +341 -0
- package/dist/clients/TorrentClient.js.map +1 -0
- package/dist/clients/Transmission.d.ts +43 -0
- package/dist/clients/Transmission.js +404 -0
- package/dist/clients/Transmission.js.map +1 -0
- package/dist/cmd.d.ts +2 -0
- package/dist/cmd.js +128 -0
- package/dist/cmd.js.map +1 -0
- package/dist/configSchema.d.ts +1 -0
- package/dist/configSchema.js +2 -0
- package/dist/configSchema.js.map +1 -0
- package/dist/configuration.d.ts +63 -0
- package/dist/configuration.js +321 -0
- package/dist/configuration.js.map +1 -0
- package/dist/constants.d.ts +108 -0
- package/dist/constants.js +251 -0
- package/dist/constants.js.map +1 -0
- package/dist/dataFiles.d.ts +8 -0
- package/dist/dataFiles.js +223 -0
- package/dist/dataFiles.js.map +1 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +216 -0
- package/dist/db.js.map +1 -0
- package/dist/dbConfig.d.ts +4 -0
- package/dist/dbConfig.js +67 -0
- package/dist/dbConfig.js.map +1 -0
- package/dist/decide.d.ts +25 -0
- package/dist/decide.js +553 -0
- package/dist/decide.js.map +1 -0
- package/dist/diff.d.ts +1 -0
- package/dist/diff.js +24 -0
- package/dist/diff.js.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/indexers.d.ts +105 -0
- package/dist/indexers.js +248 -0
- package/dist/indexers.js.map +1 -0
- package/dist/inject.d.ts +2 -0
- package/dist/inject.js +594 -0
- package/dist/inject.js.map +1 -0
- package/dist/jobs.d.ts +29 -0
- package/dist/jobs.js +151 -0
- package/dist/jobs.js.map +1 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +157 -0
- package/dist/logger.js.map +1 -0
- package/dist/migrations/00-initialSchema.d.ts +9 -0
- package/dist/migrations/00-initialSchema.js +30 -0
- package/dist/migrations/00-initialSchema.js.map +1 -0
- package/dist/migrations/01-jobs.d.ts +9 -0
- package/dist/migrations/01-jobs.js +12 -0
- package/dist/migrations/01-jobs.js.map +1 -0
- package/dist/migrations/02-timestamps.d.ts +9 -0
- package/dist/migrations/02-timestamps.js +21 -0
- package/dist/migrations/02-timestamps.js.map +1 -0
- package/dist/migrations/03-rateLimits.d.ts +9 -0
- package/dist/migrations/03-rateLimits.js +14 -0
- package/dist/migrations/03-rateLimits.js.map +1 -0
- package/dist/migrations/04-auth.d.ts +9 -0
- package/dist/migrations/04-auth.js +13 -0
- package/dist/migrations/04-auth.js.map +1 -0
- package/dist/migrations/05-caps.d.ts +9 -0
- package/dist/migrations/05-caps.js +16 -0
- package/dist/migrations/05-caps.js.map +1 -0
- package/dist/migrations/06-uniqueDecisions.d.ts +9 -0
- package/dist/migrations/06-uniqueDecisions.js +29 -0
- package/dist/migrations/06-uniqueDecisions.js.map +1 -0
- package/dist/migrations/07-limits.d.ts +9 -0
- package/dist/migrations/07-limits.js +12 -0
- package/dist/migrations/07-limits.js.map +1 -0
- package/dist/migrations/08-rss.d.ts +9 -0
- package/dist/migrations/08-rss.js +15 -0
- package/dist/migrations/08-rss.js.map +1 -0
- package/dist/migrations/09-clientAndDataSearchees.d.ts +9 -0
- package/dist/migrations/09-clientAndDataSearchees.js +34 -0
- package/dist/migrations/09-clientAndDataSearchees.js.map +1 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.d.ts +9 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.js +18 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.js.map +1 -0
- package/dist/migrations/11-trackers.d.ts +9 -0
- package/dist/migrations/11-trackers.js +38 -0
- package/dist/migrations/11-trackers.js.map +1 -0
- package/dist/migrations/12-user-auth.d.ts +9 -0
- package/dist/migrations/12-user-auth.js +22 -0
- package/dist/migrations/12-user-auth.js.map +1 -0
- package/dist/migrations/13-settings.d.ts +9 -0
- package/dist/migrations/13-settings.js +23 -0
- package/dist/migrations/13-settings.js.map +1 -0
- package/dist/migrations/14-indexer-enabled-flag.d.ts +9 -0
- package/dist/migrations/14-indexer-enabled-flag.js +12 -0
- package/dist/migrations/14-indexer-enabled-flag.js.map +1 -0
- package/dist/migrations/15-remove-url-unique-constraint.d.ts +9 -0
- package/dist/migrations/15-remove-url-unique-constraint.js +14 -0
- package/dist/migrations/15-remove-url-unique-constraint.js.map +1 -0
- package/dist/migrations/16-prune-inactive-indexers.d.ts +9 -0
- package/dist/migrations/16-prune-inactive-indexers.js +17 -0
- package/dist/migrations/16-prune-inactive-indexers.js.map +1 -0
- package/dist/migrations/migrations.d.ts +13 -0
- package/dist/migrations/migrations.js +41 -0
- package/dist/migrations/migrations.js.map +1 -0
- package/dist/parseTorrent.d.ts +53 -0
- package/dist/parseTorrent.js +128 -0
- package/dist/parseTorrent.js.map +1 -0
- package/dist/pipeline.d.ts +41 -0
- package/dist/pipeline.js +574 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/preFilter.d.ts +25 -0
- package/dist/preFilter.js +250 -0
- package/dist/preFilter.js.map +1 -0
- package/dist/problems/linking.d.ts +2 -0
- package/dist/problems/linking.js +80 -0
- package/dist/problems/linking.js.map +1 -0
- package/dist/problems/path.d.ts +22 -0
- package/dist/problems/path.js +96 -0
- package/dist/problems/path.js.map +1 -0
- package/dist/problems.d.ts +13 -0
- package/dist/problems.js +48 -0
- package/dist/problems.js.map +1 -0
- package/dist/pushNotifier.d.ts +19 -0
- package/dist/pushNotifier.js +137 -0
- package/dist/pushNotifier.js.map +1 -0
- package/dist/routes/baseApi.d.ts +2 -0
- package/dist/routes/baseApi.js +354 -0
- package/dist/routes/baseApi.js.map +1 -0
- package/dist/routes/indexerApi.d.ts +6 -0
- package/dist/routes/indexerApi.js +165 -0
- package/dist/routes/indexerApi.js.map +1 -0
- package/dist/routes/staticFrontendPlugin.d.ts +4 -0
- package/dist/routes/staticFrontendPlugin.js +63 -0
- package/dist/routes/staticFrontendPlugin.js.map +1 -0
- package/dist/runtimeConfig.d.ts +6 -0
- package/dist/runtimeConfig.js +27 -0
- package/dist/runtimeConfig.js.map +1 -0
- package/dist/searchee.d.ts +108 -0
- package/dist/searchee.js +689 -0
- package/dist/searchee.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +65 -0
- package/dist/server.js.map +1 -0
- package/dist/services/indexerService.d.ts +96 -0
- package/dist/services/indexerService.js +287 -0
- package/dist/services/indexerService.js.map +1 -0
- package/dist/sessionCookies.d.ts +5 -0
- package/dist/sessionCookies.js +27 -0
- package/dist/sessionCookies.js.map +1 -0
- package/dist/startup.d.ts +25 -0
- package/dist/startup.js +157 -0
- package/dist/startup.js.map +1 -0
- package/dist/torrent.d.ts +69 -0
- package/dist/torrent.js +641 -0
- package/dist/torrent.js.map +1 -0
- package/dist/torznab.d.ts +60 -0
- package/dist/torznab.js +711 -0
- package/dist/torznab.js.map +1 -0
- package/dist/trpc/fastifyAdapter.d.ts +2 -0
- package/dist/trpc/fastifyAdapter.js +9 -0
- package/dist/trpc/fastifyAdapter.js.map +1 -0
- package/dist/trpc/index.d.ts +49 -0
- package/dist/trpc/index.js +53 -0
- package/dist/trpc/index.js.map +1 -0
- package/dist/trpc/routers/auth.d.ts +43 -0
- package/dist/trpc/routers/auth.js +116 -0
- package/dist/trpc/routers/auth.js.map +1 -0
- package/dist/trpc/routers/clients.d.ts +21 -0
- package/dist/trpc/routers/clients.js +65 -0
- package/dist/trpc/routers/clients.js.map +1 -0
- package/dist/trpc/routers/health.d.ts +14 -0
- package/dist/trpc/routers/health.js +20 -0
- package/dist/trpc/routers/health.js.map +1 -0
- package/dist/trpc/routers/index.d.ts +391 -0
- package/dist/trpc/routers/index.js +23 -0
- package/dist/trpc/routers/index.js.map +1 -0
- package/dist/trpc/routers/indexers.d.ts +75 -0
- package/dist/trpc/routers/indexers.js +79 -0
- package/dist/trpc/routers/indexers.js.map +1 -0
- package/dist/trpc/routers/jobs.d.ts +33 -0
- package/dist/trpc/routers/jobs.js +84 -0
- package/dist/trpc/routers/jobs.js.map +1 -0
- package/dist/trpc/routers/logs.d.ts +27 -0
- package/dist/trpc/routers/logs.js +91 -0
- package/dist/trpc/routers/logs.js.map +1 -0
- package/dist/trpc/routers/searchees.d.ts +51 -0
- package/dist/trpc/routers/searchees.js +156 -0
- package/dist/trpc/routers/searchees.js.map +1 -0
- package/dist/trpc/routers/settings.d.ts +83 -0
- package/dist/trpc/routers/settings.js +92 -0
- package/dist/trpc/routers/settings.js.map +1 -0
- package/dist/trpc/routers/stats.d.ts +42 -0
- package/dist/trpc/routers/stats.js +102 -0
- package/dist/trpc/routers/stats.js.map +1 -0
- package/dist/userAuth.d.ts +21 -0
- package/dist/userAuth.js +86 -0
- package/dist/userAuth.js.map +1 -0
- package/dist/utils/authUtils.d.ts +10 -0
- package/dist/utils/authUtils.js +24 -0
- package/dist/utils/authUtils.js.map +1 -0
- package/dist/utils/logWatcher.d.ts +28 -0
- package/dist/utils/logWatcher.js +218 -0
- package/dist/utils/logWatcher.js.map +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/object.js +4 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils.d.ts +175 -0
- package/dist/utils.js +660 -0
- package/dist/utils.js.map +1 -0
- package/package.json +17 -58
- package/LICENSE +0 -201
- package/README.md +0 -33
- package/dist/webui/assets/FieldInfo-Bxj_j8SJ.js +0 -1
- package/dist/webui/assets/Page-C3rteCZt.js +0 -1
- package/dist/webui/assets/array-field-DVSC6nHP.js +0 -1
- package/dist/webui/assets/badge-DTZMtS0e.js +0 -1
- package/dist/webui/assets/check-Bu3ldi63.js +0 -1
- package/dist/webui/assets/chevron-down-CRy8M0kJ.js +0 -1
- package/dist/webui/assets/clients-CW8oEZoQ.js +0 -1
- package/dist/webui/assets/connect-YBNsnjWT.js +0 -1
- package/dist/webui/assets/debug-mz8-WYZj.js +0 -1
- package/dist/webui/assets/directories-BSK28RgR.js +0 -1
- package/dist/webui/assets/duration-field-C6xoSlJg.js +0 -1
- package/dist/webui/assets/general-lJJxZhH7.js +0 -1
- package/dist/webui/assets/health-CXbsVrie.js +0 -1
- package/dist/webui/assets/index-Bi48hI2z.js +0 -54
- package/dist/webui/assets/index-C-Ul7GNg.css +0 -1
- package/dist/webui/assets/index-C2cH1Gst.js +0 -1
- package/dist/webui/assets/index-Cc5bDmJr.js +0 -1
- package/dist/webui/assets/jobs-CxmNab9w.js +0 -1
- package/dist/webui/assets/library-vaj2W8sE.js +0 -1
- package/dist/webui/assets/loader-circle-M0gu1gZ-.js +0 -1
- package/dist/webui/assets/logs-Cu9RyKS0.js +0 -1
- package/dist/webui/assets/search-2R5sIdT8.js +0 -1
- package/dist/webui/assets/select-field-BCqNLDrJ.js +0 -1
- package/dist/webui/assets/select-zHgqMzLj.js +0 -1
- package/dist/webui/assets/settings-CMYjpTbZ.js +0 -1
- package/dist/webui/assets/submit-button-BtcnyggQ.js +0 -1
- package/dist/webui/assets/switch-G0W3uJVN.js +0 -1
- package/dist/webui/assets/switch-field-IBd9ORNq.js +0 -1
- package/dist/webui/assets/table-DvgJU7Gh.js +0 -1
- package/dist/webui/assets/test-tube-BIwmoM45.js +0 -1
- package/dist/webui/assets/text-field-DruSbGhy.js +0 -1
- package/dist/webui/assets/time-BSMZjmyW.js +0 -1
- package/dist/webui/assets/trackers-D-OpAe63.js +0 -7
- package/dist/webui/assets/use-form-validation-context-BkAfWAh0.js +0 -1
- package/dist/webui/assets/use-settings-form-submit-CDRh-E9U.js +0 -2
- package/dist/webui/assets/useQuery-A4Hv_4uX.js +0 -1
- package/dist/webui/index.html +0 -13
- package/node_modules/@cross-seed/shared/dist/configSchema.d.ts +0 -261
- package/node_modules/@cross-seed/shared/dist/configSchema.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/configSchema.js +0 -53
- package/node_modules/@cross-seed/shared/dist/configSchema.js.map +0 -1
- package/node_modules/@cross-seed/shared/dist/constants.d.ts +0 -122
- package/node_modules/@cross-seed/shared/dist/constants.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/constants.js +0 -127
- package/node_modules/@cross-seed/shared/dist/constants.js.map +0 -1
- package/node_modules/@cross-seed/shared/dist/tsconfig.tsbuildinfo +0 -1
- package/node_modules/@cross-seed/shared/dist/utils.d.ts +0 -6
- package/node_modules/@cross-seed/shared/dist/utils.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/utils.js +0 -9
- package/node_modules/@cross-seed/shared/dist/utils.js.map +0 -1
- package/node_modules/@cross-seed/shared/package.json +0 -22
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { readdir } from "fs/promises";
|
|
2
|
+
import ms from "ms";
|
|
3
|
+
import { basename } from "path";
|
|
4
|
+
import { inspect } from "util";
|
|
5
|
+
import { InjectionResult, TORRENT_TAG, USER_AGENT, } from "../constants.js";
|
|
6
|
+
import { db } from "../db.js";
|
|
7
|
+
import { CrossSeedError } from "../errors.js";
|
|
8
|
+
import { Label, logger } from "../logger.js";
|
|
9
|
+
import { resultOf, resultOfErr } from "../Result.js";
|
|
10
|
+
import { getRuntimeConfig } from "../runtimeConfig.js";
|
|
11
|
+
import { createSearcheeFromDB, parseTitle, updateSearcheeClientDB, } from "../searchee.js";
|
|
12
|
+
import { extractCredentialsFromUrl, humanReadableSize, sanitizeInfoHash, wait, } from "../utils.js";
|
|
13
|
+
import { shouldResumeFromNonRelevantFiles, clientSearcheeModified, getMaxRemainingBytes, getResumeStopTime, organizeTrackers, resumeErrSleepTime, resumeSleepTime, shouldRecheck, } from "./TorrentClient.js";
|
|
14
|
+
const XTransmissionSessionId = "X-Transmission-Session-Id";
|
|
15
|
+
function doesAlreadyExist(args) {
|
|
16
|
+
return "torrent-duplicate" in args;
|
|
17
|
+
}
|
|
18
|
+
export default class Transmission {
|
|
19
|
+
xTransmissionSessionId;
|
|
20
|
+
url;
|
|
21
|
+
clientHost;
|
|
22
|
+
clientPriority;
|
|
23
|
+
clientType = Label.TRANSMISSION;
|
|
24
|
+
readonly;
|
|
25
|
+
label;
|
|
26
|
+
constructor(url, clientHost, priority, readonly) {
|
|
27
|
+
this.url = url;
|
|
28
|
+
this.clientHost = clientHost;
|
|
29
|
+
this.clientPriority = priority;
|
|
30
|
+
this.readonly = readonly;
|
|
31
|
+
this.label = `${this.clientType}@${this.clientHost}`;
|
|
32
|
+
}
|
|
33
|
+
async request(method, args = {}, retries = 1, timeout = 0) {
|
|
34
|
+
const msg = `Calling method ${method} with params ${inspect(args, { depth: null, compact: true })}`;
|
|
35
|
+
const message = msg.length > 1000 ? `${msg.slice(0, 1000)}...` : msg;
|
|
36
|
+
logger.verbose({ label: this.label, message });
|
|
37
|
+
const { username, password, href } = extractCredentialsFromUrl(this.url).unwrapOrThrow(new CrossSeedError(`[${this.label}] Transmission rpc url must be percent-encoded`));
|
|
38
|
+
const headers = new Headers({ "User-Agent": USER_AGENT });
|
|
39
|
+
headers.set("Content-Type", "application/json");
|
|
40
|
+
if (this.xTransmissionSessionId) {
|
|
41
|
+
headers.set(XTransmissionSessionId, this.xTransmissionSessionId);
|
|
42
|
+
}
|
|
43
|
+
if (username && password) {
|
|
44
|
+
const credentials = Buffer.from(`${username}:${password}`).toString("base64");
|
|
45
|
+
headers.set("Authorization", `Basic ${credentials}`);
|
|
46
|
+
}
|
|
47
|
+
const response = await fetch(href, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
body: JSON.stringify({ method, arguments: args }),
|
|
50
|
+
headers,
|
|
51
|
+
signal: AbortSignal.timeout(timeout || ms("5 minutes")),
|
|
52
|
+
});
|
|
53
|
+
if (response.status === 409) {
|
|
54
|
+
this.xTransmissionSessionId = response.headers.get(XTransmissionSessionId);
|
|
55
|
+
return this.request(method, args, retries - 1);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const responseBody = (await response.clone().json());
|
|
59
|
+
if (responseBody.result === "success" ||
|
|
60
|
+
responseBody.result === "duplicate torrent" // slight hack but best solution for now
|
|
61
|
+
) {
|
|
62
|
+
return responseBody.arguments;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error(`Transmission responded with error: "${responseBody.result}"`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (e instanceof SyntaxError) {
|
|
70
|
+
logger.error({
|
|
71
|
+
label: this.label,
|
|
72
|
+
message: `Transmission returned non-JSON response`,
|
|
73
|
+
});
|
|
74
|
+
logger.debug({
|
|
75
|
+
label: this.label,
|
|
76
|
+
message: response.clone().text(),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
logger.error({
|
|
81
|
+
label: this.label,
|
|
82
|
+
message: `Transmission responded with an error: ${e.message}`,
|
|
83
|
+
});
|
|
84
|
+
logger.debug(e);
|
|
85
|
+
}
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async validateConfig() {
|
|
90
|
+
const { torrentDir } = getRuntimeConfig();
|
|
91
|
+
try {
|
|
92
|
+
await this.request("session-get", {}, 1, ms("10 seconds"));
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
throw new CrossSeedError(`[${this.label}] Failed to reach Transmission at ${this.clientHost}: ${e.message}`);
|
|
96
|
+
}
|
|
97
|
+
logger.info({
|
|
98
|
+
label: this.label,
|
|
99
|
+
message: `Logged in successfully${this.readonly ? " (readonly)" : ""}`,
|
|
100
|
+
});
|
|
101
|
+
if (!torrentDir)
|
|
102
|
+
return;
|
|
103
|
+
if (!(await readdir(torrentDir)).some((f) => f.endsWith(".torrent"))) {
|
|
104
|
+
throw new CrossSeedError(`[${this.label}] Invalid torrentDir, if no torrents are in client set to null for now: https://www.cross-seed.org/docs/basics/options#torrentdir`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async checkOriginalTorrent(data, onlyCompleted) {
|
|
108
|
+
let queryResponse;
|
|
109
|
+
try {
|
|
110
|
+
queryResponse = await this.request("torrent-get", {
|
|
111
|
+
fields: ["downloadDir", "percentDone"],
|
|
112
|
+
ids: [data.infoHash],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return resultOfErr(InjectionResult.FAILURE);
|
|
117
|
+
}
|
|
118
|
+
if (queryResponse.torrents.length === 0) {
|
|
119
|
+
return resultOfErr(InjectionResult.FAILURE);
|
|
120
|
+
}
|
|
121
|
+
const [{ downloadDir, percentDone }] = queryResponse.torrents;
|
|
122
|
+
if (onlyCompleted && percentDone < 1) {
|
|
123
|
+
return resultOfErr(InjectionResult.TORRENT_NOT_COMPLETE);
|
|
124
|
+
}
|
|
125
|
+
return resultOf({ downloadDir });
|
|
126
|
+
}
|
|
127
|
+
async getDownloadDir(meta, options) {
|
|
128
|
+
const result = await this.checkOriginalTorrent(meta, options.onlyCompleted);
|
|
129
|
+
return result
|
|
130
|
+
.mapOk((r) => r.downloadDir)
|
|
131
|
+
.mapErr((err) => (err === "FAILURE" ? "UNKNOWN_ERROR" : err));
|
|
132
|
+
}
|
|
133
|
+
async getAllDownloadDirs(options) {
|
|
134
|
+
let torrents = (await this.request("torrent-get", {
|
|
135
|
+
fields: ["hashString", "downloadDir", "percentDone"],
|
|
136
|
+
})).torrents;
|
|
137
|
+
if (options.onlyCompleted) {
|
|
138
|
+
torrents = torrents.filter((torrent) => torrent.percentDone === 1);
|
|
139
|
+
}
|
|
140
|
+
return torrents.reduce((acc, { hashString, downloadDir }) => {
|
|
141
|
+
acc.set(hashString, downloadDir);
|
|
142
|
+
return acc;
|
|
143
|
+
}, new Map());
|
|
144
|
+
}
|
|
145
|
+
async isTorrentInClient(inputHash) {
|
|
146
|
+
const infoHash = inputHash.toLowerCase();
|
|
147
|
+
try {
|
|
148
|
+
const torrents = (await this.request("torrent-get", {
|
|
149
|
+
fields: ["hashString"],
|
|
150
|
+
})).torrents;
|
|
151
|
+
if (!torrents.length)
|
|
152
|
+
throw new Error("No torrents found");
|
|
153
|
+
for (const torrent of torrents) {
|
|
154
|
+
if (torrent.hashString.toLowerCase() === infoHash) {
|
|
155
|
+
return resultOf(true);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return resultOf(false);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return resultOfErr(e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async isTorrentComplete(infoHash) {
|
|
165
|
+
const queryResponse = await this.request("torrent-get", {
|
|
166
|
+
fields: ["percentDone"],
|
|
167
|
+
ids: [infoHash],
|
|
168
|
+
});
|
|
169
|
+
if (queryResponse.torrents.length === 0) {
|
|
170
|
+
return resultOfErr("NOT_FOUND");
|
|
171
|
+
}
|
|
172
|
+
const [{ percentDone }] = queryResponse.torrents;
|
|
173
|
+
return resultOf(percentDone === 1);
|
|
174
|
+
}
|
|
175
|
+
async isTorrentChecking(infoHash) {
|
|
176
|
+
const queryResponse = await this.request("torrent-get", {
|
|
177
|
+
fields: ["status"],
|
|
178
|
+
ids: [infoHash],
|
|
179
|
+
});
|
|
180
|
+
if (queryResponse.torrents.length === 0) {
|
|
181
|
+
return resultOfErr("NOT_FOUND");
|
|
182
|
+
}
|
|
183
|
+
const [{ status }] = queryResponse.torrents;
|
|
184
|
+
return resultOf([1, 2].includes(status));
|
|
185
|
+
}
|
|
186
|
+
async getAllTorrents() {
|
|
187
|
+
const res = await this.request("torrent-get", {
|
|
188
|
+
fields: ["hashString", "labels"],
|
|
189
|
+
});
|
|
190
|
+
return res.torrents.map((torrent) => ({
|
|
191
|
+
infoHash: torrent.hashString,
|
|
192
|
+
tags: torrent.labels,
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
async getClientSearchees(options) {
|
|
196
|
+
const searchees = [];
|
|
197
|
+
const newSearchees = [];
|
|
198
|
+
const infoHashes = new Set();
|
|
199
|
+
let torrents;
|
|
200
|
+
try {
|
|
201
|
+
torrents = (await this.request("torrent-get", {
|
|
202
|
+
fields: [
|
|
203
|
+
"hashString",
|
|
204
|
+
"name",
|
|
205
|
+
"files",
|
|
206
|
+
"totalSize",
|
|
207
|
+
"downloadDir",
|
|
208
|
+
"labels",
|
|
209
|
+
"trackers",
|
|
210
|
+
],
|
|
211
|
+
})).torrents;
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
logger.error({
|
|
215
|
+
label: this.label,
|
|
216
|
+
message: `Failed to get torrents from client: ${e.message}`,
|
|
217
|
+
});
|
|
218
|
+
logger.debug(e);
|
|
219
|
+
return { searchees, newSearchees };
|
|
220
|
+
}
|
|
221
|
+
if (!torrents.length) {
|
|
222
|
+
logger.error({
|
|
223
|
+
label: this.label,
|
|
224
|
+
message: "No torrents found in client",
|
|
225
|
+
});
|
|
226
|
+
return { searchees, newSearchees };
|
|
227
|
+
}
|
|
228
|
+
for (const torrent of torrents) {
|
|
229
|
+
const infoHash = torrent.hashString.toLowerCase();
|
|
230
|
+
infoHashes.add(infoHash);
|
|
231
|
+
const dbTorrent = await db("client_searchee")
|
|
232
|
+
.where("info_hash", infoHash)
|
|
233
|
+
.where("client_host", this.clientHost)
|
|
234
|
+
.first();
|
|
235
|
+
const { name } = torrent;
|
|
236
|
+
const savePath = torrent.downloadDir;
|
|
237
|
+
const tags = torrent.labels;
|
|
238
|
+
const modified = clientSearcheeModified(this.label, dbTorrent, name, savePath, {
|
|
239
|
+
tags,
|
|
240
|
+
});
|
|
241
|
+
const refresh = options?.refresh === undefined
|
|
242
|
+
? false
|
|
243
|
+
: options.refresh.length === 0
|
|
244
|
+
? true
|
|
245
|
+
: options.refresh.includes(infoHash);
|
|
246
|
+
if (!modified && !refresh) {
|
|
247
|
+
if (!options?.newSearcheesOnly) {
|
|
248
|
+
searchees.push(createSearcheeFromDB(dbTorrent));
|
|
249
|
+
}
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const files = torrent.files.map((file) => ({
|
|
253
|
+
name: basename(file.name),
|
|
254
|
+
path: file.name,
|
|
255
|
+
length: file.length,
|
|
256
|
+
}));
|
|
257
|
+
if (!files.length) {
|
|
258
|
+
logger.verbose({
|
|
259
|
+
label: this.label,
|
|
260
|
+
message: `No files found for ${torrent.name} [${sanitizeInfoHash(infoHash)}]: skipping`,
|
|
261
|
+
});
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const trackers = organizeTrackers(torrent.trackers.map((tracker) => ({
|
|
265
|
+
url: tracker.announce,
|
|
266
|
+
tier: tracker.tier,
|
|
267
|
+
})));
|
|
268
|
+
const title = parseTitle(name, files) ?? name;
|
|
269
|
+
const length = torrent.totalSize;
|
|
270
|
+
const searchee = {
|
|
271
|
+
infoHash,
|
|
272
|
+
name,
|
|
273
|
+
title,
|
|
274
|
+
files,
|
|
275
|
+
length,
|
|
276
|
+
clientHost: this.clientHost,
|
|
277
|
+
savePath,
|
|
278
|
+
tags,
|
|
279
|
+
trackers,
|
|
280
|
+
};
|
|
281
|
+
newSearchees.push(searchee);
|
|
282
|
+
searchees.push(searchee);
|
|
283
|
+
}
|
|
284
|
+
await updateSearcheeClientDB(this.clientHost, newSearchees, infoHashes);
|
|
285
|
+
return { searchees, newSearchees };
|
|
286
|
+
}
|
|
287
|
+
async recheckTorrent(infoHash) {
|
|
288
|
+
// Pause first as it may resume after recheck automatically
|
|
289
|
+
await this.request("torrent-stop", {
|
|
290
|
+
ids: [infoHash],
|
|
291
|
+
});
|
|
292
|
+
await this.request("torrent-verify", {
|
|
293
|
+
ids: [infoHash],
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
async resumeInjection(meta, decision, options) {
|
|
297
|
+
const infoHash = meta.infoHash;
|
|
298
|
+
let sleepTime = resumeSleepTime;
|
|
299
|
+
const stopTime = getResumeStopTime();
|
|
300
|
+
let stop = false;
|
|
301
|
+
while (Date.now() < stopTime) {
|
|
302
|
+
if (options.checkOnce) {
|
|
303
|
+
if (stop)
|
|
304
|
+
return;
|
|
305
|
+
stop = true;
|
|
306
|
+
}
|
|
307
|
+
await wait(sleepTime);
|
|
308
|
+
const queryResponse = await this.request("torrent-get", {
|
|
309
|
+
fields: ["leftUntilDone", "name", "status"],
|
|
310
|
+
ids: [infoHash],
|
|
311
|
+
});
|
|
312
|
+
if (queryResponse.torrents.length === 0) {
|
|
313
|
+
sleepTime = resumeErrSleepTime; // Dropping connections or restart
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
const [{ leftUntilDone, name, status }] = queryResponse.torrents;
|
|
317
|
+
if ([1, 2].includes(status)) {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
const torrentLog = `${name} [${sanitizeInfoHash(infoHash)}]`;
|
|
321
|
+
if (status !== 0) {
|
|
322
|
+
logger.warn({
|
|
323
|
+
label: this.label,
|
|
324
|
+
message: `Will not resume ${torrentLog}: status is ${status}`,
|
|
325
|
+
});
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const maxRemainingBytes = getMaxRemainingBytes(meta, decision, {
|
|
329
|
+
torrentLog,
|
|
330
|
+
label: this.label,
|
|
331
|
+
});
|
|
332
|
+
if (leftUntilDone > maxRemainingBytes) {
|
|
333
|
+
if (!shouldResumeFromNonRelevantFiles(meta, leftUntilDone, decision, {
|
|
334
|
+
torrentLog,
|
|
335
|
+
label: this.label,
|
|
336
|
+
})) {
|
|
337
|
+
logger.warn({
|
|
338
|
+
label: this.label,
|
|
339
|
+
message: `autoResumeMaxDownload will not resume ${torrentLog}: remainingSize ${humanReadableSize(leftUntilDone, { binary: true })} > ${humanReadableSize(maxRemainingBytes, { binary: true })} limit`,
|
|
340
|
+
});
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
logger.info({
|
|
345
|
+
label: this.label,
|
|
346
|
+
message: `Resuming ${torrentLog}: ${humanReadableSize(leftUntilDone, { binary: true })} remaining`,
|
|
347
|
+
});
|
|
348
|
+
await this.request("torrent-start", {
|
|
349
|
+
ids: [infoHash],
|
|
350
|
+
});
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
logger.warn({
|
|
354
|
+
label: this.label,
|
|
355
|
+
message: `Will not resume torrent ${infoHash}: timeout`,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
async inject(newTorrent, searchee, decision, options) {
|
|
359
|
+
const existsRes = await this.isTorrentInClient(newTorrent.infoHash);
|
|
360
|
+
if (existsRes.isErr())
|
|
361
|
+
return InjectionResult.FAILURE;
|
|
362
|
+
if (existsRes.unwrap())
|
|
363
|
+
return InjectionResult.ALREADY_EXISTS;
|
|
364
|
+
let destinationDir;
|
|
365
|
+
if (options.destinationDir) {
|
|
366
|
+
destinationDir = options.destinationDir;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
const result = await this.getDownloadDir(searchee, { onlyCompleted: options.onlyCompleted });
|
|
370
|
+
if (result.isOk()) {
|
|
371
|
+
destinationDir = result.unwrap();
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
if (result.unwrapErr() === "TORRENT_NOT_COMPLETE") {
|
|
375
|
+
return InjectionResult.TORRENT_NOT_COMPLETE;
|
|
376
|
+
}
|
|
377
|
+
return InjectionResult.FAILURE;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
let addResponse;
|
|
381
|
+
try {
|
|
382
|
+
const toRecheck = shouldRecheck(newTorrent, decision);
|
|
383
|
+
addResponse = await this.request("torrent-add", {
|
|
384
|
+
"download-dir": destinationDir,
|
|
385
|
+
metainfo: newTorrent.encode().toString("base64"),
|
|
386
|
+
paused: toRecheck,
|
|
387
|
+
labels: [TORRENT_TAG],
|
|
388
|
+
});
|
|
389
|
+
if (toRecheck) {
|
|
390
|
+
void this.resumeInjection(newTorrent, decision, {
|
|
391
|
+
checkOnce: false,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
return InjectionResult.FAILURE;
|
|
397
|
+
}
|
|
398
|
+
if (doesAlreadyExist(addResponse)) {
|
|
399
|
+
return InjectionResult.ALREADY_EXISTS;
|
|
400
|
+
}
|
|
401
|
+
return InjectionResult.SUCCESS;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
//# sourceMappingURL=Transmission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transmission.js","sourceRoot":"","sources":["../../src/clients/Transmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAEN,eAAe,EACf,WAAW,EACX,UAAU,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAU,QAAQ,EAAE,WAAW,EAAE,MAAM,cA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|
4
|
+
import { getApiKey, resetApiKey } from "./auth.js";
|
|
5
|
+
import { PROGRAM_NAME, PROGRAM_VERSION } from "./constants.js";
|
|
6
|
+
import { db } from "./db.js";
|
|
7
|
+
import { updateTorrentCache } from "./decide.js";
|
|
8
|
+
import { diffCmd } from "./diff.js";
|
|
9
|
+
import { clearIndexerFailures } from "./indexers.js";
|
|
10
|
+
import { injectSavedTorrents, restoreFromTorrentCache } from "./inject.js";
|
|
11
|
+
import { jobsLoop } from "./jobs.js";
|
|
12
|
+
import { bulkSearch, scanRssFeeds } from "./pipeline.js";
|
|
13
|
+
import { sendTestNotification } from "./pushNotifier.js";
|
|
14
|
+
import { serve } from "./server.js";
|
|
15
|
+
import { withFullRuntime, withMinimalRuntime } from "./startup.js";
|
|
16
|
+
import { indexTorrentsAndDataDirs, parseTorrentFromPath } from "./torrent.js";
|
|
17
|
+
import { resetUsers } from "./userAuth.js";
|
|
18
|
+
const verboseOption = new Option("-v, --verbose", "Log verbose output").default(false);
|
|
19
|
+
program.name(PROGRAM_NAME);
|
|
20
|
+
program.description(chalk.yellow.bold(`${PROGRAM_NAME} v${PROGRAM_VERSION}`));
|
|
21
|
+
program.version(PROGRAM_VERSION, "-V, --version", "output the current version");
|
|
22
|
+
program
|
|
23
|
+
.command("update-torrent-cache-trackers")
|
|
24
|
+
.description("Update announce urls in the torrent cache")
|
|
25
|
+
.usage("<old-announce-url> <new-announce-url>")
|
|
26
|
+
.argument("old-announce-url", 'A substring of the announce url to replace, e.g. update-torrent-cache-trackers "old.example.com" "new.example.com"')
|
|
27
|
+
.argument("new-announce-url", 'A substring of the new announce url to replace the old one with, e.g. update-torrent-cache-trackers "myoldpasskey" "mynewpasskey"')
|
|
28
|
+
.action(withMinimalRuntime(updateTorrentCache));
|
|
29
|
+
program
|
|
30
|
+
.command("diff")
|
|
31
|
+
.description("Analyze two torrent files for cross-seed compatibility")
|
|
32
|
+
.argument("searchee")
|
|
33
|
+
.argument("candidate")
|
|
34
|
+
.action(withMinimalRuntime(diffCmd, { migrate: false }));
|
|
35
|
+
program
|
|
36
|
+
.command("tree")
|
|
37
|
+
.description("Print a torrent's file tree")
|
|
38
|
+
.argument("torrent")
|
|
39
|
+
.action(withMinimalRuntime(async (torrentPath) => {
|
|
40
|
+
console.log("Use `cross-seed diff` to compare two .torrent files");
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
+
const { category, isSingleFileTorrent, raw, tags, ...meta } = await parseTorrentFromPath(torrentPath);
|
|
43
|
+
console.log(meta);
|
|
44
|
+
}, { migrate: false }));
|
|
45
|
+
program
|
|
46
|
+
.command("clear-indexer-failures")
|
|
47
|
+
.description("Clear the cached details of indexers (failures and caps)")
|
|
48
|
+
.action(withMinimalRuntime(clearIndexerFailures));
|
|
49
|
+
program
|
|
50
|
+
.command("clear-cache")
|
|
51
|
+
.description("Clear the cache without causing torrents to be re-snatched and reset the timestamps for excludeOlder and excludeRecentSearch")
|
|
52
|
+
.action(withMinimalRuntime(async () => {
|
|
53
|
+
console.log("Clearing cache...");
|
|
54
|
+
await db("decision").whereNull("info_hash").del();
|
|
55
|
+
await db("timestamp").del();
|
|
56
|
+
}));
|
|
57
|
+
program
|
|
58
|
+
.command("clear-client-cache")
|
|
59
|
+
.description("Clear cross-seed's cache of your client's torrents. Only necessary if you have recently changed clients or modified the torrents in client and don't want to wait on the cleanup job.")
|
|
60
|
+
.action(withMinimalRuntime(async () => {
|
|
61
|
+
console.log("Clearing client cache...");
|
|
62
|
+
await db("torrent").del();
|
|
63
|
+
await db("client_searchee").del();
|
|
64
|
+
await db("data").del();
|
|
65
|
+
await db("ensemble").del();
|
|
66
|
+
}));
|
|
67
|
+
program
|
|
68
|
+
.command("api-key")
|
|
69
|
+
.description("Show the api key")
|
|
70
|
+
.addOption(new Option("--api-key <key>", "Provide your own API key to override the autogenerated one."))
|
|
71
|
+
.action(withMinimalRuntime(getApiKey));
|
|
72
|
+
program
|
|
73
|
+
.command("reset-api-key")
|
|
74
|
+
.description("Reset the api key")
|
|
75
|
+
.action(withMinimalRuntime(resetApiKey));
|
|
76
|
+
program
|
|
77
|
+
.command("reset-user")
|
|
78
|
+
.description("Delete all users and sessions")
|
|
79
|
+
.action(withMinimalRuntime(resetUsers));
|
|
80
|
+
program
|
|
81
|
+
.command("daemon")
|
|
82
|
+
.description("Start the cross-seed daemon")
|
|
83
|
+
.option("-p, --port <port>", "Listen on a custom port", (n) => parseInt(n))
|
|
84
|
+
.option("--host <host>", "Bind to a specific IP address")
|
|
85
|
+
.option("--base-path <path>", "Serve cross-seed behind this base path", "")
|
|
86
|
+
.option("--no-port", "Do not listen on any port")
|
|
87
|
+
.addOption(verboseOption)
|
|
88
|
+
.action(withFullRuntime(async (options) => {
|
|
89
|
+
const serverPromise = serve(options.port, options.host, options.basePath);
|
|
90
|
+
await indexTorrentsAndDataDirs({ startup: true });
|
|
91
|
+
// technically this will never resolve, but it's necessary to keep the process running
|
|
92
|
+
await Promise.all([serverPromise, jobsLoop()]);
|
|
93
|
+
}));
|
|
94
|
+
program
|
|
95
|
+
.command("rss")
|
|
96
|
+
.description("Run an rss scan")
|
|
97
|
+
.addOption(verboseOption)
|
|
98
|
+
.action(withFullRuntime(async () => {
|
|
99
|
+
await indexTorrentsAndDataDirs({ startup: true });
|
|
100
|
+
await scanRssFeeds();
|
|
101
|
+
}));
|
|
102
|
+
program
|
|
103
|
+
.command("search")
|
|
104
|
+
.description("Search for cross-seeds")
|
|
105
|
+
.addOption(new Option("--torrents <torrents...>", "torrent files separated by spaces").hideHelp())
|
|
106
|
+
.addOption(verboseOption)
|
|
107
|
+
.action(withFullRuntime(() => bulkSearch()));
|
|
108
|
+
program
|
|
109
|
+
.command("inject")
|
|
110
|
+
.description("Inject saved cross-seeds into your client (without filtering, see docs)")
|
|
111
|
+
.option("--inject-dir <dir>", "Directory of torrent files to try to inject")
|
|
112
|
+
.option("--ignore-titles", "Searchee and candidate titles do not need to pass the fuzzy matching check (useful if `cross-seed inject` erroneously rejects by title)")
|
|
113
|
+
.option("--no-ignore-titles", "Searchee and candidate titles need to pass the fuzzy matching check (default)")
|
|
114
|
+
.addOption(verboseOption)
|
|
115
|
+
.action(withFullRuntime(injectSavedTorrents));
|
|
116
|
+
program
|
|
117
|
+
.command("restore")
|
|
118
|
+
.description("Use snatched torrents from torrent_cache to attempt to restore cross seeds. Will need to run `cross-seed inject` afterwards with dataDirs configured.")
|
|
119
|
+
.addOption(verboseOption)
|
|
120
|
+
.action(withFullRuntime(restoreFromTorrentCache));
|
|
121
|
+
program
|
|
122
|
+
.command("test-notification")
|
|
123
|
+
.description("Send a test notification")
|
|
124
|
+
.addOption(verboseOption)
|
|
125
|
+
.action(withFullRuntime(sendTestNotification));
|
|
126
|
+
program.showHelpAfterError("(add --help for additional information)");
|
|
127
|
+
await program.parseAsync();
|
|
128
|
+
//# sourceMappingURL=cmd.js.map
|
package/dist/cmd.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cmd.js","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAA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C;AAEhD,OAAO,CAAC,kBAAkB,CAAC,yCAAyC,CAAC,CAAC;AAEtE,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RUNTIME_CONFIG_SCHEMA, RUNTIME_CONFIG_OVERRIDES_SCHEMA, parseRuntimeConfig, parseRuntimeConfigOverrides, } from "@cross-seed/shared/configSchema";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../src/configSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,+BAA+B,EAC/B,kBAAkB,EAClB,2BAA2B,GAC3B,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Action, MatchMode } from "./constants.js";
|
|
2
|
+
import { RuntimeConfig } from "./runtimeConfig.js";
|
|
3
|
+
export interface FileConfig {
|
|
4
|
+
action?: Action;
|
|
5
|
+
pconfigVersion?: number;
|
|
6
|
+
delay?: number;
|
|
7
|
+
includeSingleEpisodes?: boolean;
|
|
8
|
+
outputDir?: string;
|
|
9
|
+
injectDir?: string;
|
|
10
|
+
ignoreTitles?: boolean;
|
|
11
|
+
includeNonVideos?: boolean;
|
|
12
|
+
seasonFromEpisodes?: number;
|
|
13
|
+
fuzzySizeThreshold?: number;
|
|
14
|
+
excludeOlder?: string;
|
|
15
|
+
excludeRecentSearch?: string;
|
|
16
|
+
useClientTorrents?: boolean;
|
|
17
|
+
dataDirs?: string[];
|
|
18
|
+
matchMode?: MatchMode;
|
|
19
|
+
skipRecheck?: boolean;
|
|
20
|
+
autoResumeMaxDownload?: number;
|
|
21
|
+
ignoreNonRelevantFilesToResume?: boolean;
|
|
22
|
+
linkDir?: string;
|
|
23
|
+
linkDirs?: string[];
|
|
24
|
+
linkType?: string;
|
|
25
|
+
flatLinking?: boolean;
|
|
26
|
+
maxDataDepth?: number;
|
|
27
|
+
linkCategory?: string;
|
|
28
|
+
torrentDir?: string;
|
|
29
|
+
torznab?: string[];
|
|
30
|
+
torrentClients?: string[];
|
|
31
|
+
qbittorrentUrl?: string;
|
|
32
|
+
rtorrentRpcUrl?: string;
|
|
33
|
+
transmissionRpcUrl?: string;
|
|
34
|
+
delugeRpcUrl?: string;
|
|
35
|
+
duplicateCategories?: boolean;
|
|
36
|
+
notificationWebhookUrls?: string[];
|
|
37
|
+
notificationWebhookUrl?: string;
|
|
38
|
+
port?: number;
|
|
39
|
+
host?: string;
|
|
40
|
+
searchCadence?: string;
|
|
41
|
+
rssCadence?: string;
|
|
42
|
+
snatchTimeout?: string;
|
|
43
|
+
searchTimeout?: string;
|
|
44
|
+
searchLimit?: number;
|
|
45
|
+
blockList?: string[];
|
|
46
|
+
apiKey?: string;
|
|
47
|
+
sonarr?: string[];
|
|
48
|
+
radarr?: string[];
|
|
49
|
+
}
|
|
50
|
+
export declare const UNPARSABLE_CONFIG_MESSAGE: string;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the appDir relevant to the OS/Environment. Due to initialization of
|
|
53
|
+
* the SQLiteDB during read of db.ts - will need to create appDir in this function if
|
|
54
|
+
* it does not exist (ENOENT)
|
|
55
|
+
*
|
|
56
|
+
* @return a string representing the absolute path to cross-seed config directory
|
|
57
|
+
*/
|
|
58
|
+
export declare function appDir(): string;
|
|
59
|
+
export declare function createAppDirHierarchy(): void;
|
|
60
|
+
export declare function getDefaultRuntimeConfig(): RuntimeConfig;
|
|
61
|
+
export declare function stripDefaults(config: Partial<RuntimeConfig> | RuntimeConfig): Partial<RuntimeConfig>;
|
|
62
|
+
export declare function transformFileConfig(fileConfig: FileConfig): Partial<RuntimeConfig>;
|
|
63
|
+
export declare function getFileConfig(): Promise<FileConfig | undefined>;
|