patreon-dl 2.2.0 → 2.4.0
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/README.md +20 -1
- package/bin/patreon-dl-vimeo.js +0 -2
- package/dist/cli/CLIOptionValidator.d.ts +2 -1
- package/dist/cli/CLIOptionValidator.d.ts.map +1 -1
- package/dist/cli/CLIOptionValidator.js +20 -1
- package/dist/cli/CLIOptionValidator.js.map +1 -1
- package/dist/cli/CLIOptions.d.ts.map +1 -1
- package/dist/cli/CLIOptions.js +17 -3
- package/dist/cli/CLIOptions.js.map +1 -1
- package/dist/cli/ConfigFileParser.d.ts.map +1 -1
- package/dist/cli/ConfigFileParser.js +23 -8
- package/dist/cli/ConfigFileParser.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +18 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/downloaders/Downloader.d.ts.map +1 -1
- package/dist/downloaders/Downloader.js +3 -0
- package/dist/downloaders/Downloader.js.map +1 -1
- package/dist/downloaders/DownloaderOptions.d.ts +11 -2
- package/dist/downloaders/DownloaderOptions.d.ts.map +1 -1
- package/dist/downloaders/DownloaderOptions.js +30 -4
- package/dist/downloaders/DownloaderOptions.js.map +1 -1
- package/dist/downloaders/PostDownloader.d.ts.map +1 -1
- package/dist/downloaders/PostDownloader.js +458 -261
- package/dist/downloaders/PostDownloader.js.map +1 -1
- package/dist/downloaders/PostsFetcher.js +2 -2
- package/dist/downloaders/PostsFetcher.js.map +1 -1
- package/dist/downloaders/ProductDownloader.d.ts.map +1 -1
- package/dist/downloaders/ProductDownloader.js +3 -1
- package/dist/downloaders/ProductDownloader.js.map +1 -1
- package/dist/downloaders/cache/StatusCache.d.ts +22 -9
- package/dist/downloaders/cache/StatusCache.d.ts.map +1 -1
- package/dist/downloaders/cache/StatusCache.js +87 -34
- package/dist/downloaders/cache/StatusCache.js.map +1 -1
- package/dist/downloaders/index.d.ts +1 -1
- package/dist/downloaders/index.d.ts.map +1 -1
- package/dist/downloaders/index.js +1 -0
- package/dist/downloaders/index.js.map +1 -1
- package/dist/downloaders/task/DownloadTaskBatch.js +1 -1
- package/dist/downloaders/task/DownloadTaskBatch.js.map +1 -1
- package/dist/downloaders/task/DownloadTaskFactory.d.ts.map +1 -1
- package/dist/downloaders/task/DownloadTaskFactory.js +3 -0
- package/dist/downloaders/task/DownloadTaskFactory.js.map +1 -1
- package/dist/downloaders/task/FFmpegDownloadTaskBase.d.ts.map +1 -1
- package/dist/downloaders/task/FFmpegDownloadTaskBase.js +30 -3
- package/dist/downloaders/task/FFmpegDownloadTaskBase.js.map +1 -1
- package/dist/downloaders/task/FetcherDownloadTask.d.ts.map +1 -1
- package/dist/downloaders/task/FetcherDownloadTask.js +5 -1
- package/dist/downloaders/task/FetcherDownloadTask.js.map +1 -1
- package/dist/downloaders/task/YouTubeDownloadTask.js +1 -1
- package/dist/downloaders/task/YouTubeDownloadTask.js.map +1 -1
- package/dist/downloaders/templates/CommentInfo.d.ts +3 -0
- package/dist/downloaders/templates/CommentInfo.d.ts.map +1 -0
- package/dist/downloaders/templates/CommentInfo.js +38 -0
- package/dist/downloaders/templates/CommentInfo.js.map +1 -0
- package/dist/entities/Collection.d.ts +7 -0
- package/dist/entities/Collection.d.ts.map +1 -0
- package/dist/entities/Collection.js +2 -0
- package/dist/entities/Collection.js.map +1 -0
- package/dist/entities/Comment.d.ts +16 -0
- package/dist/entities/Comment.d.ts.map +1 -0
- package/dist/entities/Comment.js +2 -0
- package/dist/entities/Comment.js.map +1 -0
- package/dist/entities/Post.d.ts +5 -7
- package/dist/entities/Post.d.ts.map +1 -1
- package/dist/entities/Post.js.map +1 -1
- package/dist/parsers/CommentParser.d.ts +8 -0
- package/dist/parsers/CommentParser.d.ts.map +1 -0
- package/dist/parsers/CommentParser.js +91 -0
- package/dist/parsers/CommentParser.js.map +1 -0
- package/dist/parsers/Parser.d.ts +1 -0
- package/dist/parsers/Parser.d.ts.map +1 -1
- package/dist/parsers/Parser.js +14 -0
- package/dist/parsers/Parser.js.map +1 -1
- package/dist/parsers/PostParser.d.ts +1 -1
- package/dist/parsers/PostParser.d.ts.map +1 -1
- package/dist/parsers/PostParser.js +59 -50
- package/dist/parsers/PostParser.js.map +1 -1
- package/dist/utils/FSHelper.d.ts +14 -13
- package/dist/utils/FSHelper.d.ts.map +1 -1
- package/dist/utils/FSHelper.js.map +1 -1
- package/dist/utils/Fetcher.d.ts.map +1 -1
- package/dist/utils/Fetcher.js +24 -7
- package/dist/utils/Fetcher.js.map +1 -1
- package/dist/utils/FllenameResolver.d.ts +1 -0
- package/dist/utils/FllenameResolver.d.ts.map +1 -1
- package/dist/utils/FllenameResolver.js.map +1 -1
- package/dist/utils/MediaFilenameResolver.d.ts +1 -0
- package/dist/utils/MediaFilenameResolver.d.ts.map +1 -1
- package/dist/utils/MediaFilenameResolver.js.map +1 -1
- package/dist/utils/ObjectHelper.js +1 -1
- package/dist/utils/ObjectHelper.js.map +1 -1
- package/dist/utils/Progress.d.ts +1 -0
- package/dist/utils/Progress.d.ts.map +1 -1
- package/dist/utils/Progress.js.map +1 -1
- package/dist/utils/Proxy.d.ts +9 -0
- package/dist/utils/Proxy.d.ts.map +1 -0
- package/dist/utils/Proxy.js +66 -0
- package/dist/utils/Proxy.js.map +1 -0
- package/dist/utils/URLHelper.d.ts +9 -0
- package/dist/utils/URLHelper.d.ts.map +1 -1
- package/dist/utils/URLHelper.js +104 -1
- package/dist/utils/URLHelper.js.map +1 -1
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logging/ConsoleLogger.d.ts +12 -0
- package/dist/utils/logging/ConsoleLogger.d.ts.map +1 -1
- package/dist/utils/logging/ConsoleLogger.js +3 -0
- package/dist/utils/logging/ConsoleLogger.js.map +1 -1
- package/dist/utils/logging/FileLogger.d.ts +1 -0
- package/dist/utils/logging/FileLogger.d.ts.map +1 -1
- package/dist/utils/logging/FileLogger.js +3 -0
- package/dist/utils/logging/FileLogger.js.map +1 -1
- package/dist/utils/yt/InnertubeLoader.d.ts +2 -1
- package/dist/utils/yt/InnertubeLoader.d.ts.map +1 -1
- package/dist/utils/yt/InnertubeLoader.js +19 -5
- package/dist/utils/yt/InnertubeLoader.js.map +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ A Patreon downloader written in [Node.js](https://nodejs.org).
|
|
|
19
19
|
- Save campaign and content info
|
|
20
20
|
- Extensively configurable
|
|
21
21
|
|
|
22
|
-
You can run `patreon-dl` from the command-line or [use it as a library](./docs/Library.md) for your project. Node.js
|
|
22
|
+
You can run `patreon-dl` from the command-line or [use it as a library](./docs/Library.md) for your project. Node.js v20 or higher required.
|
|
23
23
|
|
|
24
24
|
### Limitations
|
|
25
25
|
|
|
@@ -96,6 +96,7 @@ https://www.patreon.com/<creator>/shop/<slug>-<product_id>
|
|
|
96
96
|
// Download posts by creator
|
|
97
97
|
https://www.patreon.com/<creator>/posts
|
|
98
98
|
https://www.patreon.com/c/<creator>/posts
|
|
99
|
+
https://www.patreon.com/cw/<creator>/posts
|
|
99
100
|
https://www.patreon.com/user/posts?u=<user_id>
|
|
100
101
|
|
|
101
102
|
// Dowload a single post
|
|
@@ -175,6 +176,7 @@ include.posts.in.tier = 123456, 789100
|
|
|
175
176
|
# include.images.by.filename
|
|
176
177
|
# include.audio.by.filename
|
|
177
178
|
# include.attachments.by.filename
|
|
179
|
+
# include.comments
|
|
178
180
|
|
|
179
181
|
# URL 2
|
|
180
182
|
https://www.patreon.com/janedoe/posts
|
|
@@ -221,6 +223,23 @@ Note that you can override an option from a configuration file with one provided
|
|
|
221
223
|
|
|
222
224
|
## Changelog
|
|
223
225
|
|
|
226
|
+
v2.4.0
|
|
227
|
+
- Support additional URL format: `https://www.patreon.com/cw/<creator>/posts`
|
|
228
|
+
- Add `stopOn` option ([#63](https://github.com/patrickkfkan/patreon-dl/issues/63))
|
|
229
|
+
- Add `proxy` option ([#62](https://github.com/patrickkfkan/patreon-dl/issues/62))
|
|
230
|
+
- Fix Vimeo download script
|
|
231
|
+
- Fix YouTube embeds failing to download due to YT changes
|
|
232
|
+
- API changes (non-breaking):
|
|
233
|
+
- Expose `URLHelper`, `FetcherError`
|
|
234
|
+
- Add `getDefaultDownloaderOptions()`
|
|
235
|
+
- `ConsoleLogger` / `FileLogger`: add `getDefaultConfig()`
|
|
236
|
+
- Required Node version bumped to v20.18.1 or higher
|
|
237
|
+
|
|
238
|
+
v2.3.0
|
|
239
|
+
- Add `podcast` type to `include.postsWithMediaType` option
|
|
240
|
+
- Add `include.comments` option
|
|
241
|
+
- Fix videos not downloaded in podcast-type posts ([#56](https://github.com/patrickkfkan/patreon-dl/issues/56))
|
|
242
|
+
|
|
224
243
|
v2.2.0
|
|
225
244
|
- Widen scope of external downloaders to any type of embed (previously only works for video embeds) ([#51](https://github.com/patrickkfkan/patreon-dl/issues/51))
|
|
226
245
|
- YouTube downloading now covers embedded YT links
|
package/bin/patreon-dl-vimeo.js
CHANGED
|
@@ -9,10 +9,11 @@ export default class CLIOptionValidator {
|
|
|
9
9
|
static validateStringArray<T>(entry: CLIOptionParserEntry | undefined, match?: readonly T[], delimiter?: string): T[] | undefined;
|
|
10
10
|
static validateTargetURLs(value: string | string[], delimiter?: string): string[];
|
|
11
11
|
static validateTargetURL(s: string): string;
|
|
12
|
-
static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry): "none" | ("attachment" | "audio" | "video" | "image")[] | "any" | undefined;
|
|
12
|
+
static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry): "none" | ("attachment" | "audio" | "video" | "image" | "podcast")[] | "any" | undefined;
|
|
13
13
|
static validateIncludeContentInTier(entry?: CLIOptionParserEntry): string[] | "any" | undefined;
|
|
14
14
|
static validateIncludePreviewMedia(entry?: CLIOptionParserEntry): boolean | ("audio" | "video" | "image")[] | undefined;
|
|
15
15
|
static validateIncludeContentMedia(entry?: CLIOptionParserEntry): boolean | ("attachment" | "file" | "audio" | "video" | "image")[] | undefined;
|
|
16
16
|
static validateDateTime(entry?: CLIOptionParserEntry): DateTime | undefined;
|
|
17
|
+
static validateProxyURL(entry?: CLIOptionParserEntry): string;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=CLIOptionValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLIOptionValidator.d.ts","sourceRoot":"","sources":["../../src/cli/CLIOptionValidator.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAQ5D,MAAM,CAAC,OAAO,OAAO,kBAAkB;;IAErC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,MAAM;IAarE,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS;IAW3G,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,oBAAoB;IA0BnD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAoB9E,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,SAAM;IAyB5G,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,SAAM,GAAG,MAAM,EAAE;IAQ9E,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM;IAoBlC,MAAM,CA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C,EAAE,MAAM;IAoBlC,MAAM,CAAC,mCAAmC,CAAC,KAAK,CAAC,EAAE,oBAAoB;IASvE,MAAM,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAShE,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAS/D,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAS/D,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAapD,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,oBAAoB;CAgCrD"}
|
|
@@ -133,7 +133,7 @@ class CLIOptionValidator {
|
|
|
133
133
|
return this.validateString(entry, 'any', 'none');
|
|
134
134
|
}
|
|
135
135
|
catch (_error) {
|
|
136
|
-
return this.validateStringArray(entry, ['image', 'video', 'audio', 'attachment']);
|
|
136
|
+
return this.validateStringArray(entry, ['image', 'video', 'audio', 'attachment', 'podcast']);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
static validateIncludeContentInTier(entry) {
|
|
@@ -172,6 +172,25 @@ class CLIOptionValidator {
|
|
|
172
172
|
throw Error(`${__classPrivateFieldGet(this, _a, "m", _CLIOptionValidator_logEntryKey).call(this, entry)} has invalid datetime string "${v}"; must be in this format: ${DateTime.FORMAT}`);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
static validateProxyURL(entry) {
|
|
176
|
+
if (!entry || !entry.value) {
|
|
177
|
+
return '';
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
const urlObj = new URL(entry.value);
|
|
181
|
+
const supportedProtocols = ['http', 'https', 'socks4', 'socks5'];
|
|
182
|
+
const urlProtocol = urlObj.protocol.endsWith(':') ? urlObj.protocol.substring(0, urlObj.protocol.length - 1) : urlObj.protocol;
|
|
183
|
+
if (!supportedProtocols.includes(urlProtocol)) {
|
|
184
|
+
throw Error(`Unsupported proxy protocol '${urlProtocol}'; must be one of ${supportedProtocols.map((p) => `'${p}'`).join(', ')}.`);
|
|
185
|
+
}
|
|
186
|
+
return urlObj.toString();
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (error instanceof Error)
|
|
190
|
+
throw Error(`${__classPrivateFieldGet(this, _a, "m", _CLIOptionValidator_logEntryKey).call(this, entry)} has invalid value: ${error.message}`);
|
|
191
|
+
throw Error(`${__classPrivateFieldGet(this, _a, "m", _CLIOptionValidator_logEntryKey).call(this, entry)} has invalid value.`, { cause: error });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
175
194
|
}
|
|
176
195
|
_a = CLIOptionValidator, _CLIOptionValidator_logEntryKey = function _CLIOptionValidator_logEntryKey(entry) {
|
|
177
196
|
const src = CLI_OPTION_SRC_NAME[entry.src];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLIOptionValidator.js","sourceRoot":"","sources":["../../src/cli/CLIOptionValidator.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAG9C,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,cAAc;CACpB,CAAC;AAEF,MAAqB,kBAAkB;IAErC,MAAM,CAAC,gBAAgB,CAAC,KAA4B,EAAE,MAAe;QACnE,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,KAAK,CAAC,2BAA2B,C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CAAC;QAC1B,CAAC;QACD,OAAO,MAAe,EAAE,CAAC;YACvB,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,iCAAiC,CAAC,8BAA8B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5H,CAAC;IACH,CAAC;CAaF;oGAXqB,KAA2B;IAC7C,MAAM,GAAG,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;QAClB,KAAK,KAAK;YACR,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,GAAG,GAAG,CAAC;QACxC,KAAK,KAAK;YACR,OAAO,GAAG,GAAG,aAAa,KAAK,CAAC,OAAO,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC;QAC5D,KAAK,KAAK;YACR,OAAO,kBAAkB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,GAAG,GAAG,CAAC;IACpG,CAAC;AACH,CAAC;eAxLkB,kBAAkB","sourcesContent":["import DateTime from '../utils/DateTime.js';\nimport URLHelper from '../utils/URLHelper.js';\nimport { type CLIOptionParserEntry } from './CLIOptions.js';\n\nconst CLI_OPTION_SRC_NAME = {\n cli: 'Command-line',\n cfg: 'Config file',\n tgt: 'Targets file'\n};\n\nexport default class CLIOptionValidator {\n\n static validateRequired(entry?: CLIOptionParserEntry, errMsg?: string) {\n if (entry && entry.value) {\n return entry.value;\n }\n if (errMsg) {\n throw Error(errMsg);\n }\n if (entry) {\n throw Error(`${this.#logEntryKey(entry)} requires a value`);\n }\n throw Error('A required option missing');\n }\n\n static validateString<T extends string[]>(entry?: CLIOptionParserEntry, ...match: T): T[number] | undefined {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n if (match.length > 0 && value && !match.includes(value)) {\n throw Error(`${this.#logEntryKey(entry)} must be one of ${match.map((m) => `'${m}'`).join(', ')}`);\n }\n return value;\n }\n\n static validateBoolean(entry?: CLIOptionParserEntry) {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n const trueValues = [ 'yes', '1', 'true' ];\n const falseValues = [ 'no', '0', 'false' ];\n let sanitized: boolean | undefined;\n if (value) {\n if (trueValues.includes(value.toLowerCase())) {\n sanitized = true;\n }\n else if (falseValues.includes(value.toLowerCase())) {\n sanitized = false;\n }\n else {\n const allowedValues = [ ...trueValues, ...falseValues ];\n throw Error(`${this.#logEntryKey(entry)} must be one of ${allowedValues.map((m) => `'${m}'`).join(', ')}; currently '${value}'`);\n }\n }\n else {\n sanitized = undefined;\n }\n return sanitized;\n }\n\n static validateNumber(entry?: CLIOptionParserEntry, min?: number, max?: number) {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n const sanitized = value ? parseInt(value, 10) : undefined;\n if (sanitized !== undefined) {\n if (isNaN(sanitized)) {\n throw Error(`${this.#logEntryKey(entry)} is not a valid number`);\n }\n else if (min !== undefined && sanitized < min) {\n throw Error(`${this.#logEntryKey(entry)} must not be less than ${min}`);\n }\n else if (max !== undefined && sanitized > max) {\n throw Error(`${this.#logEntryKey(entry)} must not be greater than ${max}`);\n }\n }\n return sanitized;\n }\n\n static validateStringArray<T>(entry: CLIOptionParserEntry | undefined, match?: readonly T[], delimiter = ',') {\n const value = entry?.value || undefined;\n if (!entry || !value) {\n return undefined;\n }\n const split = value.split(delimiter).reduce<string[]>((result, v) => {\n v = v.trim().toLowerCase();\n if (v && !result.includes(v)) {\n result.push(v);\n }\n return result;\n }, []);\n if (split.length === 0) {\n return undefined;\n }\n if (match && match.length > 0) {\n for (const v of split) {\n if (!match.includes(v as any)) {\n throw Error(`${this.#logEntryKey(entry)} has invalid delimited value '${v}'; must be one of ${match.map((m) => `'${m as string}'`).join(', ')}.`);\n }\n }\n }\n return split as T[];\n }\n\n static validateTargetURLs(value: string | string[], delimiter = ','): string[] {\n if (!Array.isArray(value)) {\n const splitted = value.split(delimiter);\n return this.validateTargetURLs(splitted);\n }\n return value.map((v) => this.validateTargetURL(v));\n }\n\n static validateTargetURL(s: string) {\n const _s = s.trim();\n try {\n const type = URLHelper.analyzeURL(_s);\n if (!type) {\n throw Error('Unknown URL');\n }\n }\n catch (error: any) {\n if (error instanceof Error) {\n error.message += `: ${_s}`;\n throw error;\n }\n else {\n throw Error(`${error}: ${_s}`);\n }\n }\n return _s;\n }\n\n static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry) {\n try {\n return this.validateString(entry, 'any', 'none');\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment' ] as const);\n }\n }\n\n static validateIncludeContentInTier(entry?: CLIOptionParserEntry) {\n try {\n return this.validateString(entry, 'any');\n }\n catch (_error: unknown) {\n return this.validateStringArray<string>(entry);\n }\n }\n\n static validateIncludePreviewMedia(entry?: CLIOptionParserEntry) {\n try {\n return this.validateBoolean(entry);\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio' ] as const);\n }\n }\n\n static validateIncludeContentMedia(entry?: CLIOptionParserEntry) {\n try {\n return this.validateBoolean(entry);\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment', 'file' ] as const);\n }\n }\n\n static validateDateTime(entry?: CLIOptionParserEntry) {\n if (!entry || !entry.value) {\n return undefined;\n }\n const v = entry.value.trim();\n try {\n return DateTime.from(v);\n }\n catch (_error: unknown) {\n throw Error(`${this.#logEntryKey(entry)} has invalid datetime string \"${v}\"; must be in this format: ${DateTime.FORMAT}`);\n }\n }\n\n static #logEntryKey(entry: CLIOptionParserEntry) {\n const src = CLI_OPTION_SRC_NAME[entry.src];\n switch (entry.src) {\n case 'cli':\n return `${src} option '${entry.key}'`;\n case 'cfg':\n return `${src} option '[${entry.section}]->${entry.key}'`;\n case 'tgt':\n return `Value given in ${src.toLowerCase()} on line ${entry.line} starting with '${entry.key}'`;\n }\n }\n}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K,CAAC,GAAG,GAAG,CAAC;QAC5D,KAAK,KAAK;YACR,OAAO,kBAAkB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,GAAG,GAAG,CAAC;IACpG,CAAC;AACH,CAAC;eA7MkB,kBAAkB","sourcesContent":["import DateTime from '../utils/DateTime.js';\nimport URLHelper from '../utils/URLHelper.js';\nimport { type CLIOptionParserEntry } from './CLIOptions.js';\n\nconst CLI_OPTION_SRC_NAME = {\n cli: 'Command-line',\n cfg: 'Config file',\n tgt: 'Targets file'\n};\n\nexport default class CLIOptionValidator {\n\n static validateRequired(entry?: CLIOptionParserEntry, errMsg?: string) {\n if (entry && entry.value) {\n return entry.value;\n }\n if (errMsg) {\n throw Error(errMsg);\n }\n if (entry) {\n throw Error(`${this.#logEntryKey(entry)} requires a value`);\n }\n throw Error('A required option missing');\n }\n\n static validateString<T extends string[]>(entry?: CLIOptionParserEntry, ...match: T): T[number] | undefined {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n if (match.length > 0 && value && !match.includes(value)) {\n throw Error(`${this.#logEntryKey(entry)} must be one of ${match.map((m) => `'${m}'`).join(', ')}`);\n }\n return value;\n }\n\n static validateBoolean(entry?: CLIOptionParserEntry) {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n const trueValues = [ 'yes', '1', 'true' ];\n const falseValues = [ 'no', '0', 'false' ];\n let sanitized: boolean | undefined;\n if (value) {\n if (trueValues.includes(value.toLowerCase())) {\n sanitized = true;\n }\n else if (falseValues.includes(value.toLowerCase())) {\n sanitized = false;\n }\n else {\n const allowedValues = [ ...trueValues, ...falseValues ];\n throw Error(`${this.#logEntryKey(entry)} must be one of ${allowedValues.map((m) => `'${m}'`).join(', ')}; currently '${value}'`);\n }\n }\n else {\n sanitized = undefined;\n }\n return sanitized;\n }\n\n static validateNumber(entry?: CLIOptionParserEntry, min?: number, max?: number) {\n if (!entry) {\n return undefined;\n }\n const value = entry.value || undefined;\n const sanitized = value ? parseInt(value, 10) : undefined;\n if (sanitized !== undefined) {\n if (isNaN(sanitized)) {\n throw Error(`${this.#logEntryKey(entry)} is not a valid number`);\n }\n else if (min !== undefined && sanitized < min) {\n throw Error(`${this.#logEntryKey(entry)} must not be less than ${min}`);\n }\n else if (max !== undefined && sanitized > max) {\n throw Error(`${this.#logEntryKey(entry)} must not be greater than ${max}`);\n }\n }\n return sanitized;\n }\n\n static validateStringArray<T>(entry: CLIOptionParserEntry | undefined, match?: readonly T[], delimiter = ',') {\n const value = entry?.value || undefined;\n if (!entry || !value) {\n return undefined;\n }\n const split = value.split(delimiter).reduce<string[]>((result, v) => {\n v = v.trim().toLowerCase();\n if (v && !result.includes(v)) {\n result.push(v);\n }\n return result;\n }, []);\n if (split.length === 0) {\n return undefined;\n }\n if (match && match.length > 0) {\n for (const v of split) {\n if (!match.includes(v as any)) {\n throw Error(`${this.#logEntryKey(entry)} has invalid delimited value '${v}'; must be one of ${match.map((m) => `'${m as string}'`).join(', ')}.`);\n }\n }\n }\n return split as T[];\n }\n\n static validateTargetURLs(value: string | string[], delimiter = ','): string[] {\n if (!Array.isArray(value)) {\n const splitted = value.split(delimiter);\n return this.validateTargetURLs(splitted);\n }\n return value.map((v) => this.validateTargetURL(v));\n }\n\n static validateTargetURL(s: string) {\n const _s = s.trim();\n try {\n const type = URLHelper.analyzeURL(_s);\n if (!type) {\n throw Error('Unknown URL');\n }\n }\n catch (error: any) {\n if (error instanceof Error) {\n error.message += `: ${_s}`;\n throw error;\n }\n else {\n throw Error(`${error}: ${_s}`);\n }\n }\n return _s;\n }\n\n static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry) {\n try {\n return this.validateString(entry, 'any', 'none');\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment', 'podcast' ] as const);\n }\n }\n\n static validateIncludeContentInTier(entry?: CLIOptionParserEntry) {\n try {\n return this.validateString(entry, 'any');\n }\n catch (_error: unknown) {\n return this.validateStringArray<string>(entry);\n }\n }\n\n static validateIncludePreviewMedia(entry?: CLIOptionParserEntry) {\n try {\n return this.validateBoolean(entry);\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio' ] as const);\n }\n }\n\n static validateIncludeContentMedia(entry?: CLIOptionParserEntry) {\n try {\n return this.validateBoolean(entry);\n }\n catch (_error: unknown) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment', 'file' ] as const);\n }\n }\n\n static validateDateTime(entry?: CLIOptionParserEntry) {\n if (!entry || !entry.value) {\n return undefined;\n }\n const v = entry.value.trim();\n try {\n return DateTime.from(v);\n }\n catch (_error: unknown) {\n throw Error(`${this.#logEntryKey(entry)} has invalid datetime string \"${v}\"; must be in this format: ${DateTime.FORMAT}`);\n }\n }\n\n static validateProxyURL(entry?: CLIOptionParserEntry) {\n if (!entry || !entry.value) {\n return '';\n }\n try {\n const urlObj = new URL(entry.value);\n const supportedProtocols = ['http', 'https', 'socks4', 'socks5'];\n const urlProtocol = urlObj.protocol.endsWith(':') ? urlObj.protocol.substring(0, urlObj.protocol.length - 1) : urlObj.protocol;\n if (!supportedProtocols.includes(urlProtocol)) {\n throw Error(`Unsupported proxy protocol '${urlProtocol}'; must be one of ${supportedProtocols.map((p)=> `'${p}'`).join(', ')}.`);\n }\n return urlObj.toString();\n }\n catch (error: unknown) {\n if (error instanceof Error)\n throw Error(`${this.#logEntryKey(entry)} has invalid value: ${error.message}`);\n \n throw Error(`${this.#logEntryKey(entry)} has invalid value.`, { cause: error });\n }\n }\n\n static #logEntryKey(entry: CLIOptionParserEntry) {\n const src = CLI_OPTION_SRC_NAME[entry.src];\n switch (entry.src) {\n case 'cli':\n return `${src} option '${entry.key}'`;\n case 'cfg':\n return `${src} option '[${entry.section}]->${entry.key}'`;\n case 'tgt':\n return `Value given in ${src.toLowerCase()} on line ${entry.line} starting with '${entry.key}'`;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLIOptions.d.ts","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE5G,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,gBAAgD,MAAM,uBAAuB,CAAC;AAIrF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IACnE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,oBAAoB,CAAC;IACpC,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC;IAClC,GAAG,EAAE,KAAK,CAAA;CACX,GAAG;IACF,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG;IACF,GAAG,EAAE,KAAK,CAAC;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAC,GAAG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,wBAAgB,aAAa,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"CLIOptions.d.ts","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE5G,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,gBAAgD,MAAM,uBAAuB,CAAC;AAIrF,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IACnE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,oBAAoB,CAAC;IACpC,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC;IAClC,GAAG,EAAE,KAAK,CAAA;CACX,GAAG;IACF,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG;IACF,GAAG,EAAE,KAAK,CAAC;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAC,GAAG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,wBAAgB,aAAa,IAAI,UAAU,CAsD1C;AAED,wBAAgB,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;;;;;;;;;;;;;;EAsCvJ"}
|
package/dist/cli/CLIOptions.js
CHANGED
|
@@ -20,10 +20,12 @@ export function getCLIOptions() {
|
|
|
20
20
|
.map((url) => ({ url }));
|
|
21
21
|
}
|
|
22
22
|
const { consoleLogger, fileLoggers } = getCLILoggerOptions(commandLineOptions, configFileOptions);
|
|
23
|
+
const proxy = getProxyOptions(configFileOptions);
|
|
23
24
|
const options = {
|
|
24
25
|
targetURLs,
|
|
25
26
|
cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),
|
|
26
27
|
useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),
|
|
28
|
+
stopOn: CLIOptionValidator.validateString(pickDefined(commandLineOptions.stopOn, configFileOptions?.stopOn), 'never', 'postPreviouslyDownloaded', 'postPublishDateOutOfRange'),
|
|
27
29
|
pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),
|
|
28
30
|
outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),
|
|
29
31
|
dirNameFormat: {
|
|
@@ -37,7 +39,8 @@ export function getCLIOptions() {
|
|
|
37
39
|
request: {
|
|
38
40
|
maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),
|
|
39
41
|
maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),
|
|
40
|
-
minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime))
|
|
42
|
+
minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime)),
|
|
43
|
+
proxy
|
|
41
44
|
},
|
|
42
45
|
fileExistsAction: {
|
|
43
46
|
content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.content, configFileOptions?.fileExistsAction?.content), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),
|
|
@@ -112,7 +115,8 @@ function getCLIIncludeOptions(commandLineOptions, configFileOptions) {
|
|
|
112
115
|
images: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.images, configFileOptions?.include?.mediaByFilename?.images)) || null,
|
|
113
116
|
audio: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.audio, configFileOptions?.include?.mediaByFilename?.audio)) || null,
|
|
114
117
|
attachments: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.attachments, configFileOptions?.include?.mediaByFilename?.attachments)) || null
|
|
115
|
-
}
|
|
118
|
+
},
|
|
119
|
+
comments: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.comments, configFileOptions?.include?.comments))
|
|
116
120
|
};
|
|
117
121
|
}
|
|
118
122
|
function getEmbedDownloaderOptions(configFileOptions) {
|
|
@@ -124,6 +128,15 @@ function getEmbedDownloaderOptions(configFileOptions) {
|
|
|
124
128
|
}
|
|
125
129
|
return undefined;
|
|
126
130
|
}
|
|
131
|
+
function getProxyOptions(configFileOptions) {
|
|
132
|
+
if (configFileOptions?.request?.proxy && configFileOptions.request.proxy.url?.value?.trim()) {
|
|
133
|
+
return {
|
|
134
|
+
url: CLIOptionValidator.validateProxyURL(configFileOptions.request.proxy.url),
|
|
135
|
+
rejectUnauthorizedTLS: CLIOptionValidator.validateBoolean(configFileOptions.request.proxy.rejectUnauthorizedTLS)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
127
140
|
function readTargetsFile(file) {
|
|
128
141
|
const includeKeys = {
|
|
129
142
|
lockedContent: 'include.locked.content',
|
|
@@ -138,7 +151,8 @@ function readTargetsFile(file) {
|
|
|
138
151
|
allMediaVariants: 'include.all.media.variants',
|
|
139
152
|
imagesByFilename: 'include.images.by.filename',
|
|
140
153
|
audioByFilename: 'include.audio.by.filename',
|
|
141
|
-
attachmentsByFilename: 'include.attachments.by.filename'
|
|
154
|
+
attachmentsByFilename: 'include.attachments.by.filename',
|
|
155
|
+
comments: 'include.comments'
|
|
142
156
|
};
|
|
143
157
|
const lines = fs.readFileSync(file)
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CAAC,CAAC;gBACvD,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,KAAU,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YAC9D,MAAM,KAAK,CAAC,oCAAoC,EAAE,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,CAAC,GAAsB,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;gBACnE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI;aACtD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\nimport { type DownloaderIncludeOptions, type DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { type DeepPartial, type RecursivePropsTo, pickDefined } from '../utils/Misc.js';\nimport { type ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { type FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { type CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { type ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\nimport ObjectHelper from '../utils/ObjectHelper.js';\n\nexport interface CLITargetURLEntry {\n url: string;\n // Target-specific 'include' options\n include?: DownloaderIncludeOptions;\n}\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURLs: CLITargetURLEntry[];\n noPrompt: boolean;\n consoleLogger: ConsoleLoggerOptions;\n fileLoggers?: FileLoggerOptions[];\n}\n\nexport type CLIOptionParserEntry = ({\n src: 'cli'\n} | {\n src: 'cfg',\n section: string\n} | {\n src: 'tgt',\n line: number\n}) & {\n key: string;\n value?: string;\n}\n\nexport function getCLIOptions(): CLIOptions {\n const commandLineOptions = CommandLineParser.parse();\n\n const configFileOptions = commandLineOptions.configFile?.value ? ConfigFileParser.parse(commandLineOptions.configFile.value) : null;\n\n let targetURLs: CLITargetURLEntry[];\n const targetURLValue = CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURLs, configFileOptions?.targetURLs), 'No target URL specified');\n const targetsFile = path.resolve(targetURLValue);\n if (fs.existsSync(targetsFile)) {\n targetURLs = readTargetsFile(targetsFile);\n }\n else {\n targetURLs = CLIOptionValidator\n .validateTargetURLs(targetURLValue)\n .map((url) => ({ url }));\n }\n\n const { consoleLogger, fileLoggers } = getCLILoggerOptions(commandLineOptions, configFileOptions);\n\n const options: CLIOptions = {\n targetURLs,\n cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),\n useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),\n pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),\n outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),\n dirNameFormat: {\n campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))\n },\n filenameFormat: {\n media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))\n },\n include: getCLIIncludeOptions(commandLineOptions, configFileOptions),\n request: {\n maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),\n maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),\n minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime))\n },\n fileExistsAction: {\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.content, configFileOptions?.fileExistsAction?.content), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n info: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.info, configFileOptions?.fileExistsAction?.info), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n infoAPI: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.infoAPI, configFileOptions?.fileExistsAction?.infoAPI), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer')\n },\n embedDownloaders: getEmbedDownloaderOptions(configFileOptions),\n noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,\n dryRun: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.dryRun, configFileOptions?.dryRun)) || false,\n consoleLogger,\n fileLoggers\n };\n\n return options;\n}\n\nexport function getCLILoggerOptions(commandLineOptions?: CommandLineParseResult, configFileOptions?: ReturnType<typeof ConfigFileParser['parse']> | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n const consoleLogger = {\n enabled: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.enabled, configFileOptions?.consoleLogger?.enabled)),\n logLevel: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.logLevel, configFileOptions?.consoleLogger?.logLevel), 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.dateTime, configFileOptions?.consoleLogger?.include?.dateTime)),\n level: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.level, configFileOptions?.consoleLogger?.include?.level)),\n originator: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.originator, configFileOptions?.consoleLogger?.include?.originator)),\n errorStack: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.errorStack, configFileOptions?.consoleLogger?.include?.errorStack))\n },\n dateTimeFormat: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.dateTimeFormat, configFileOptions?.consoleLogger?.dateTimeFormat)),\n color: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.color, configFileOptions?.consoleLogger?.color))\n };\n let fileLoggers;\n if (configFileOptions?.fileLoggers) {\n fileLoggers = configFileOptions.fileLoggers.map((logger): FileLoggerOptions => ({\n enabled: CLIOptionValidator.validateBoolean(logger.enabled),\n logDir: CLIOptionValidator.validateString(logger.logDir),\n logFilename: CLIOptionValidator.validateString(logger.logFilename),\n fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),\n logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),\n level: CLIOptionValidator.validateBoolean(logger.include?.level),\n originator: CLIOptionValidator.validateBoolean(logger.include?.originator),\n errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)\n },\n dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),\n color: CLIOptionValidator.validateBoolean(logger.color)\n }));\n }\n return {\n consoleLogger,\n fileLoggers\n };\n}\n\nfunction getCLIIncludeOptions(commandLineOptions: CommandLineParseResult, configFileOptions?: ConfigFileParseResult | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n return {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),\n postsInTier: CLIOptionValidator.validateIncludeContentInTier(pickDefined(commandLineOptions.include?.postsInTier, configFileOptions?.include?.postsInTier)),\n postsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.after, configFileOptions?.include?.postsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.before, configFileOptions?.include?.postsPublished?.before)) || null,\n },\n campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),\n contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),\n previewMedia: CLIOptionValidator.validateIncludePreviewMedia(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateIncludeContentMedia(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants)),\n mediaByFilename: {\n images: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.images, configFileOptions?.include?.mediaByFilename?.images)) || null,\n audio: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.audio, configFileOptions?.include?.mediaByFilename?.audio)) || null,\n attachments: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.attachments, configFileOptions?.include?.mediaByFilename?.attachments)) || null\n }\n };\n}\n\nfunction getEmbedDownloaderOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.embedDownloaders) {\n return configFileOptions?.embedDownloaders.map((dl) => ({\n provider: CLIOptionValidator.validateRequired(dl.provider),\n exec: CLIOptionValidator.validateRequired(dl.exec)\n }));\n }\n return undefined;\n}\n\nfunction readTargetsFile(file: string) {\n const includeKeys = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\n postsPublishedAfter: 'include.posts.published.after',\n postsPublishedBefore: 'include.posts.published.before',\n campaignInfo: 'include.campaign.info',\n contentInfo: 'include.content.info',\n previewMedia: 'include.preview.media',\n contentMedia: 'include.content.media',\n allMediaVariants: 'include.all.media.variants',\n imagesByFilename: 'include.images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include.attachments.by.filename'\n };\n\n const lines = fs.readFileSync(file)\n .toString('utf-8')\n // Replace Windows line breaks with Unix ones and then split\n .replace(/\\r\\n/g, '\\n').split('\\n')\n .map((line) => line.trim());\n\n const currentTargets: { url: string; include?: RecursivePropsTo<DeepPartial<DownloaderIncludeOptions>, CLIOptionParserEntry>; }[] = [];\n for (let ln = 0; ln < lines.length; ln++) {\n const line = lines[ln];\n if (line === '' || line.startsWith('#')) {\n continue;\n }\n try {\n const match = Object.entries(includeKeys).find((e) => line.startsWith(e[1]));\n if (match) {\n const [ optName, matchKey ] = match;\n const eq = line.indexOf('=');\n const propValue = (eq >= matchKey.length ? line.substring(eq + 1) : '').trim();\n if (propValue) {\n const target = currentTargets.at(-1);\n if (target) {\n const entry: CLIOptionParserEntry = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n if (!target.include) {\n target.include = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter || matchKey === includeKeys.postsPublishedBefore) {\n if (!target.include.postsPublished) {\n target.include.postsPublished = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter) {\n target.include.postsPublished.after = entry;\n }\n else {\n target.include.postsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.imagesByFilename || matchKey === includeKeys.audioByFilename ||\n matchKey === includeKeys.attachmentsByFilename) {\n if (!target.include.mediaByFilename) {\n target.include.mediaByFilename = {};\n }\n switch (matchKey) {\n case includeKeys.imagesByFilename:\n target.include.mediaByFilename.images = entry;\n break;\n case includeKeys.audioByFilename:\n target.include.mediaByFilename.audio = entry;\n break;\n case includeKeys.attachmentsByFilename:\n target.include.mediaByFilename.attachments = entry;\n break;\n }\n }\n else {\n target.include[optName as keyof DownloaderIncludeOptions] = entry;\n }\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error: any) {\n const errMsg = error instanceof Error ? error.message : error;\n throw Error(`Error parsing targets file (line ${ln})${errMsg ? `: ${errMsg}` : ''}`);\n }\n }\n\n const result: CLITargetURLEntry[] = [];\n for (const target of currentTargets) {\n const v: CLITargetURLEntry = { url: target.url };\n if (target.include) {\n const includeOpts = ObjectHelper.clean(getCLIIncludeOptions(target), {\n deep: true, cleanNulls: true, cleanEmptyObjects: true\n });\n if (Object.entries(includeOpts).length > 0) {\n v.include = includeOpts;\n }\n }\n result.push(v);\n }\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAA2C,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGxF,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,iBA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IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI;aACtD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\nimport { type DownloaderIncludeOptions, type DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { type DeepPartial, type RecursivePropsTo, pickDefined } from '../utils/Misc.js';\nimport { type ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { type FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { type CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { type ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\nimport ObjectHelper from '../utils/ObjectHelper.js';\n\nexport interface CLITargetURLEntry {\n url: string;\n // Target-specific 'include' options\n include?: DownloaderIncludeOptions;\n}\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURLs: CLITargetURLEntry[];\n noPrompt: boolean;\n consoleLogger: ConsoleLoggerOptions;\n fileLoggers?: FileLoggerOptions[];\n}\n\nexport type CLIOptionParserEntry = ({\n src: 'cli'\n} | {\n src: 'cfg',\n section: string\n} | {\n src: 'tgt',\n line: number\n}) & {\n key: string;\n value?: string;\n}\n\nexport function getCLIOptions(): CLIOptions {\n const commandLineOptions = CommandLineParser.parse();\n\n const configFileOptions = commandLineOptions.configFile?.value ? ConfigFileParser.parse(commandLineOptions.configFile.value) : null;\n\n let targetURLs: CLITargetURLEntry[];\n const targetURLValue = CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURLs, configFileOptions?.targetURLs), 'No target URL specified');\n const targetsFile = path.resolve(targetURLValue);\n if (fs.existsSync(targetsFile)) {\n targetURLs = readTargetsFile(targetsFile);\n }\n else {\n targetURLs = CLIOptionValidator\n .validateTargetURLs(targetURLValue)\n .map((url) => ({ url }));\n }\n\n const { consoleLogger, fileLoggers } = getCLILoggerOptions(commandLineOptions, configFileOptions);\n const proxy = getProxyOptions(configFileOptions);\n\n const options: CLIOptions = {\n targetURLs,\n cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),\n useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),\n stopOn: CLIOptionValidator.validateString(pickDefined(commandLineOptions.stopOn, configFileOptions?.stopOn), 'never', 'postPreviouslyDownloaded', 'postPublishDateOutOfRange'),\n pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),\n outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),\n dirNameFormat: {\n campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))\n },\n filenameFormat: {\n media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))\n },\n include: getCLIIncludeOptions(commandLineOptions, configFileOptions),\n request: {\n maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),\n maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),\n minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime)),\n proxy\n },\n fileExistsAction: {\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.content, configFileOptions?.fileExistsAction?.content), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n info: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.info, configFileOptions?.fileExistsAction?.info), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n infoAPI: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.infoAPI, configFileOptions?.fileExistsAction?.infoAPI), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer')\n },\n embedDownloaders: getEmbedDownloaderOptions(configFileOptions),\n noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,\n dryRun: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.dryRun, configFileOptions?.dryRun)) || false,\n consoleLogger,\n fileLoggers\n };\n\n return options;\n}\n\nexport function getCLILoggerOptions(commandLineOptions?: CommandLineParseResult, configFileOptions?: ReturnType<typeof ConfigFileParser['parse']> | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n const consoleLogger = {\n enabled: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.enabled, configFileOptions?.consoleLogger?.enabled)),\n logLevel: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.logLevel, configFileOptions?.consoleLogger?.logLevel), 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.dateTime, configFileOptions?.consoleLogger?.include?.dateTime)),\n level: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.level, configFileOptions?.consoleLogger?.include?.level)),\n originator: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.originator, configFileOptions?.consoleLogger?.include?.originator)),\n errorStack: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.errorStack, configFileOptions?.consoleLogger?.include?.errorStack))\n },\n dateTimeFormat: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.dateTimeFormat, configFileOptions?.consoleLogger?.dateTimeFormat)),\n color: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.color, configFileOptions?.consoleLogger?.color))\n };\n let fileLoggers;\n if (configFileOptions?.fileLoggers) {\n fileLoggers = configFileOptions.fileLoggers.map((logger): FileLoggerOptions => ({\n enabled: CLIOptionValidator.validateBoolean(logger.enabled),\n logDir: CLIOptionValidator.validateString(logger.logDir),\n logFilename: CLIOptionValidator.validateString(logger.logFilename),\n fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),\n logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),\n level: CLIOptionValidator.validateBoolean(logger.include?.level),\n originator: CLIOptionValidator.validateBoolean(logger.include?.originator),\n errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)\n },\n dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),\n color: CLIOptionValidator.validateBoolean(logger.color)\n }));\n }\n return {\n consoleLogger,\n fileLoggers\n };\n}\n\nfunction getCLIIncludeOptions(commandLineOptions: CommandLineParseResult, configFileOptions?: ConfigFileParseResult | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n return {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),\n postsInTier: CLIOptionValidator.validateIncludeContentInTier(pickDefined(commandLineOptions.include?.postsInTier, configFileOptions?.include?.postsInTier)),\n postsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.after, configFileOptions?.include?.postsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.before, configFileOptions?.include?.postsPublished?.before)) || null,\n },\n campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),\n contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),\n previewMedia: CLIOptionValidator.validateIncludePreviewMedia(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateIncludeContentMedia(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants)),\n mediaByFilename: {\n images: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.images, configFileOptions?.include?.mediaByFilename?.images)) || null,\n audio: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.audio, configFileOptions?.include?.mediaByFilename?.audio)) || null,\n attachments: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.attachments, configFileOptions?.include?.mediaByFilename?.attachments)) || null\n },\n comments: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.comments, configFileOptions?.include?.comments))\n };\n}\n\nfunction getEmbedDownloaderOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.embedDownloaders) {\n return configFileOptions?.embedDownloaders.map((dl) => ({\n provider: CLIOptionValidator.validateRequired(dl.provider),\n exec: CLIOptionValidator.validateRequired(dl.exec)\n }));\n }\n return undefined;\n}\n\nfunction getProxyOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.request?.proxy && configFileOptions.request.proxy.url?.value?.trim()) {\n return {\n url: CLIOptionValidator.validateProxyURL(configFileOptions.request.proxy.url),\n rejectUnauthorizedTLS: CLIOptionValidator.validateBoolean(configFileOptions.request.proxy.rejectUnauthorizedTLS)\n };\n }\n return null;\n}\n\nfunction readTargetsFile(file: string) {\n const includeKeys = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\n postsPublishedAfter: 'include.posts.published.after',\n postsPublishedBefore: 'include.posts.published.before',\n campaignInfo: 'include.campaign.info',\n contentInfo: 'include.content.info',\n previewMedia: 'include.preview.media',\n contentMedia: 'include.content.media',\n allMediaVariants: 'include.all.media.variants',\n imagesByFilename: 'include.images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include.attachments.by.filename',\n comments: 'include.comments'\n };\n\n const lines = fs.readFileSync(file)\n .toString('utf-8')\n // Replace Windows line breaks with Unix ones and then split\n .replace(/\\r\\n/g, '\\n').split('\\n')\n .map((line) => line.trim());\n\n const currentTargets: { url: string; include?: RecursivePropsTo<DeepPartial<DownloaderIncludeOptions>, CLIOptionParserEntry>; }[] = [];\n for (let ln = 0; ln < lines.length; ln++) {\n const line = lines[ln];\n if (line === '' || line.startsWith('#')) {\n continue;\n }\n try {\n const match = Object.entries(includeKeys).find((e) => line.startsWith(e[1]));\n if (match) {\n const [ optName, matchKey ] = match;\n const eq = line.indexOf('=');\n const propValue = (eq >= matchKey.length ? line.substring(eq + 1) : '').trim();\n if (propValue) {\n const target = currentTargets.at(-1);\n if (target) {\n const entry: CLIOptionParserEntry = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n if (!target.include) {\n target.include = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter || matchKey === includeKeys.postsPublishedBefore) {\n if (!target.include.postsPublished) {\n target.include.postsPublished = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter) {\n target.include.postsPublished.after = entry;\n }\n else {\n target.include.postsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.imagesByFilename || matchKey === includeKeys.audioByFilename ||\n matchKey === includeKeys.attachmentsByFilename) {\n if (!target.include.mediaByFilename) {\n target.include.mediaByFilename = {};\n }\n switch (matchKey) {\n case includeKeys.imagesByFilename:\n target.include.mediaByFilename.images = entry;\n break;\n case includeKeys.audioByFilename:\n target.include.mediaByFilename.audio = entry;\n break;\n case includeKeys.attachmentsByFilename:\n target.include.mediaByFilename.attachments = entry;\n break;\n }\n }\n else {\n target.include[optName as keyof DownloaderIncludeOptions] = entry;\n }\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error: any) {\n const errMsg = error instanceof Error ? error.message : error;\n throw Error(`Error parsing targets file (line ${ln})${errMsg ? `: ${errMsg}` : ''}`);\n }\n }\n\n const result: CLITargetURLEntry[] = [];\n for (const target of currentTargets) {\n const v: CLITargetURLEntry = { url: target.url };\n if (target.include) {\n const includeOpts = ObjectHelper.clean(getCLIIncludeOptions(target), {\n deep: true, cleanNulls: true, cleanEmptyObjects: true\n });\n if (Object.entries(includeOpts).length > 0) {\n v.include = includeOpts;\n }\n }\n result.push(v);\n }\n\n return result;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigFileParser.d.ts","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfigFileParser.d.ts","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAgF3E,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,EAAE,oBAAoB,CAAC,GAAG;IACxH,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAEnC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB;CAqJlD"}
|
|
@@ -9,6 +9,7 @@ const CONFIG_FILE_PROPS = {
|
|
|
9
9
|
targetURL: 'downloader:target.url',
|
|
10
10
|
cookie: 'downloader:cookie',
|
|
11
11
|
useStatusCache: 'downloader:use.status.cache',
|
|
12
|
+
stopOn: 'downloader:stop.on',
|
|
12
13
|
noPrompt: 'downloader:no.prompt',
|
|
13
14
|
pathToFFmpeg: 'downloader:path.to.ffmpeg',
|
|
14
15
|
dryRun: 'downloader:dry.run',
|
|
@@ -38,12 +39,17 @@ const CONFIG_FILE_PROPS = {
|
|
|
38
39
|
allMediaVariants: 'include:all.media.variants',
|
|
39
40
|
imagesByFilename: 'include:images.by.filename',
|
|
40
41
|
audioByFilename: 'include.audio.by.filename',
|
|
41
|
-
attachmentsByFilename: 'include:attachments.by.filename'
|
|
42
|
+
attachmentsByFilename: 'include:attachments.by.filename',
|
|
43
|
+
comments: 'include:comments'
|
|
42
44
|
},
|
|
43
45
|
request: {
|
|
44
46
|
maxRetries: 'request:max.retries',
|
|
45
47
|
maxConcurrent: 'request:max.concurrent',
|
|
46
|
-
minTime: 'request:min.time'
|
|
48
|
+
minTime: 'request:min.time',
|
|
49
|
+
proxy: {
|
|
50
|
+
url: 'request:proxy.url',
|
|
51
|
+
rejectUnauthorizedTLS: 'request:proxy.reject.unauthorized.tls'
|
|
52
|
+
}
|
|
47
53
|
},
|
|
48
54
|
consoleLogger: {
|
|
49
55
|
enabled: 'logger.console:enabled',
|
|
@@ -87,6 +93,7 @@ class ConfigFileParser {
|
|
|
87
93
|
targetURLs: __getValue(CONFIG_FILE_PROPS.targetURL),
|
|
88
94
|
cookie: __getValue(CONFIG_FILE_PROPS.cookie),
|
|
89
95
|
useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),
|
|
96
|
+
stopOn: __getValue(CONFIG_FILE_PROPS.stopOn),
|
|
90
97
|
pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),
|
|
91
98
|
outDir: __getValue(CONFIG_FILE_PROPS.outDir),
|
|
92
99
|
dirNameFormat: {
|
|
@@ -113,12 +120,17 @@ class ConfigFileParser {
|
|
|
113
120
|
images: __getValue(CONFIG_FILE_PROPS.include.imagesByFilename),
|
|
114
121
|
audio: __getValue(CONFIG_FILE_PROPS.include.audioByFilename),
|
|
115
122
|
attachments: __getValue(CONFIG_FILE_PROPS.include.attachmentsByFilename)
|
|
116
|
-
}
|
|
123
|
+
},
|
|
124
|
+
comments: __getValue(CONFIG_FILE_PROPS.include.comments)
|
|
117
125
|
},
|
|
118
126
|
request: {
|
|
119
127
|
maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),
|
|
120
128
|
maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),
|
|
121
|
-
minTime: __getValue(CONFIG_FILE_PROPS.request.minTime)
|
|
129
|
+
minTime: __getValue(CONFIG_FILE_PROPS.request.minTime),
|
|
130
|
+
proxy: {
|
|
131
|
+
url: __getValue(CONFIG_FILE_PROPS.request.proxy.url),
|
|
132
|
+
rejectUnauthorizedTLS: __getValue(CONFIG_FILE_PROPS.request.proxy.rejectUnauthorizedTLS),
|
|
133
|
+
}
|
|
122
134
|
},
|
|
123
135
|
fileExistsAction: {
|
|
124
136
|
content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),
|
|
@@ -197,10 +209,13 @@ _a = ConfigFileParser, _ConfigFileParser_getValueFromConfigParser = function _Co
|
|
|
197
209
|
if (result.find((dl) => dl.provider?.value === provider)) {
|
|
198
210
|
throw Error(`Duplicate config file section 'embed.downloader.${provider}`);
|
|
199
211
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
212
|
+
const exec = __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec);
|
|
213
|
+
if (exec) {
|
|
214
|
+
result.push({
|
|
215
|
+
provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },
|
|
216
|
+
exec
|
|
217
|
+
});
|
|
218
|
+
}
|
|
204
219
|
return result;
|
|
205
220
|
}, []);
|
|
206
221
|
return embedDownloaders.length > 0 ? embedDownloaders : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigFileParser.js","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAIxC,MAAM,iBAAiB,GAAG;IACxB,SAAS,EAAE,uBAAuB;IAClC,MAAM,EAAE,mBAAmB;IAC3B,cAAc,EAAE,6BAA6B;IAC7C,QAAQ,EAAE,sBAAsB;IAChC,YAAY,EAAE,2BAA2B;IACzC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,gBAAgB;IACxB,aAAa,EAAE;QACb,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,gCAAgC;KAC1C;IACD,cAAc,EAAE;QACd,KAAK,EAAE,8BAA8B;KACtC;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,oCAAoC;KAC9C;IACD,OAAO,EAAE;QACP,aAAa,EAAE,wBAAwB;QACvC,kBAAkB,EAAE,+BAA+B;QACnD,WAAW,EAAE,uBAAuB;QACpC,mBAAmB,EAAE,+BAA+B;QACpD,oBAAoB,EAAE,gCAAgC;QACtD,YAAY,EAAE,uBAAuB;Q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CAAC;YACV,QAAQ,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,oBAAoB,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE;YACnG,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC;SAClE,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;eA7IkB,gBAAgB","sourcesContent":["import ConfigParser from 'configparser';\nimport { type CLIOptionParserEntry, type CLIOptions } from './CLIOptions.js';\nimport { type DeepPartial, type RecursivePropsTo } from '../utils/Misc.js';\n\nconst CONFIG_FILE_PROPS = {\n targetURL: 'downloader:target.url',\n cookie: 'downloader:cookie',\n useStatusCache: 'downloader:use.status.cache',\n noPrompt: 'downloader:no.prompt',\n pathToFFmpeg: 'downloader:path.to.ffmpeg',\n dryRun: 'downloader:dry.run',\n outDir: 'output:out.dir',\n dirNameFormat: {\n campaign: 'output:campaign.dir.name.format',\n content: 'output:content.dir.name.format'\n },\n filenameFormat: {\n media: 'output:media.filename.format'\n },\n fileExistsAction: {\n content: 'output:content.file.exists.action',\n info: 'output:info.file.exists.action',\n infoAPI: 'output:info.api.file.exists.action'\n },\n include: {\n lockedContent: 'include:locked.content',\n postsWithMediaType: 'include:posts.with.media.type',\n postsInTier: 'include:posts.in.tier',\n postsPublishedAfter: 'include:posts.published.after',\n postsPublishedBefore: 'include:posts.published.before',\n campaignInfo: 'include:campaign.info',\n contentInfo: 'include:content.info',\n previewMedia: 'include:preview.media',\n contentMedia: 'include:content.media',\n allMediaVariants: 'include:all.media.variants',\n imagesByFilename: 'include:images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include:attachments.by.filename'\n },\n request: {\n maxRetries: 'request:max.retries',\n maxConcurrent: 'request:max.concurrent',\n minTime: 'request:min.time'\n },\n consoleLogger: {\n enabled: 'logger.console:enabled',\n logLevel: 'logger.console:log.level',\n include: {\n dateTime: 'logger.console:include.date.time',\n level: 'logger.console:include.level',\n originator: 'logger.console:include.originator',\n errorStack: 'logger.console:include.error.stack'\n },\n dateTimeFormat: 'logger.console:date.time.format',\n color: 'logger.console:color'\n },\n fileLogger: {\n enabled: ':enabled',\n logDir: ':log.dir',\n logFilename: ':log.filename',\n fileExistsAction: ':file.exists.action',\n logLevel: ':log.level',\n include: {\n dateTime: ':include.date.time',\n level: ':include.level',\n originator: ':include.originator',\n errorStack: ':include.error.stack'\n },\n dateTimeFormat: ':date.time.format',\n color: ':color'\n },\n embedDownloader: {\n exec: ':exec'\n }\n};\n\nexport type ConfigFileParseResult = RecursivePropsTo<DeepPartial<Omit<CLIOptions, 'targetURLs'>>, CLIOptionParserEntry> & {\n targetURLs?: CLIOptionParserEntry;\n};\n\nexport default class ConfigFileParser {\n\n static parse(file: string): ConfigFileParseResult {\n const parser = new ConfigParser();\n\n parser.read(file);\n\n const __getValue = (prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, prop);\n };\n\n return {\n targetURLs: __getValue(CONFIG_FILE_PROPS.targetURL),\n cookie: __getValue(CONFIG_FILE_PROPS.cookie),\n useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),\n pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),\n outDir: __getValue(CONFIG_FILE_PROPS.outDir),\n dirNameFormat: {\n campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),\n content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)\n },\n filenameFormat: {\n media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)\n },\n include: {\n lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),\n postsWithMediaType: __getValue(CONFIG_FILE_PROPS.include.postsWithMediaType),\n postsInTier: __getValue(CONFIG_FILE_PROPS.include.postsInTier),\n postsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.postsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.postsPublishedBefore),\n },\n campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),\n contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),\n previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),\n contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),\n allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants),\n mediaByFilename: {\n images: __getValue(CONFIG_FILE_PROPS.include.imagesByFilename),\n audio: __getValue(CONFIG_FILE_PROPS.include.audioByFilename),\n attachments: __getValue(CONFIG_FILE_PROPS.include.attachmentsByFilename)\n }\n },\n request: {\n maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),\n maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),\n minTime: __getValue(CONFIG_FILE_PROPS.request.minTime)\n },\n fileExistsAction: {\n content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),\n info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),\n infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)\n },\n noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),\n dryRun: __getValue(CONFIG_FILE_PROPS.dryRun),\n consoleLogger: {\n enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),\n logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),\n include: {\n dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),\n level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),\n originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),\n errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),\n color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)\n },\n fileLoggers: this.#parseFileLoggerOptions(parser),\n embedDownloaders: this.#parseEmbedDownloaderOptions(parser)\n };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key, true)?.trim();\n if (value && value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1);\n }\n if (value) {\n return {\n src: 'cfg',\n section,\n key,\n value\n };\n }\n return undefined;\n }\n\n static #parseFileLoggerOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));\n\n const loggers = sections.reduce<NonNullable<ConfigFileParseResult['fileLoggers']>>((result, section) => {\n result.push({\n enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),\n logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),\n logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),\n fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),\n logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),\n include: {\n dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),\n level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),\n originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),\n errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),\n color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)\n });\n return result;\n }, []);\n\n return loggers.length > 0 ? loggers : undefined;\n }\n\n static #parseEmbedDownloaderOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('embed.downloader.'));\n const prefixLength = 'embed.downloader.'.length;\n const embedDownloaders = sections.reduce<NonNullable<ConfigFileParseResult['embedDownloaders']>>((result, section) => {\n const provider = section.substring(prefixLength).trim().toLowerCase();\n if (!provider) {\n throw Error('Config file section \\'embed.downloader.<provider>\\' is missing the provider name');\n }\n if (result.find((dl) => dl.provider?.value === provider)) {\n throw Error(`Duplicate config file section 'embed.downloader.${provider}`);\n }\n result.push({\n provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },\n exec: __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec)\n });\n return result;\n }, []);\n\n return embedDownloaders.length > 0 ? embedDownloaders : undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigFileParser.js","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAIxC,MAAM,iBAAiB,GAAG;IACxB,SAAS,EAAE,uBAAuB;IAClC,MAAM,EAAE,mBAAmB;IAC3B,cAAc,EAAE,6BAA6B;IAC7C,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,sBAAsB;IAChC,YAAY,EAAE,2BAA2B;IACzC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,gBAAgB;IACxB,aAAa,EAAE;QACb,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,gCAAgC;KAC1C;IACD,cAAc,EAAE;QACd,KAAK,EAAE,8BAA8B;KACtC;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,oCAAoC;KAC9C;IACD,OAAO,EAAE;QACP,aAAa,EAAE,wBAAwB;QACvC,kBAAkB,EAAE,+BAA+B;QACnD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AG,mBAAmB,CAAC,MAAM,CAAC;IAChD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAyD,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACnH,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACtE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,kFAAkF,CAAC,CAAC;QAClG,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;YACzD,MAAM,KAAK,CAAC,mDAAmD,QAAQ,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACzE,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,oBAAoB,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACnG,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;eAtJkB,gBAAgB","sourcesContent":["import ConfigParser from 'configparser';\nimport { type CLIOptionParserEntry, type CLIOptions } from './CLIOptions.js';\nimport { type DeepPartial, type RecursivePropsTo } from '../utils/Misc.js';\n\nconst CONFIG_FILE_PROPS = {\n targetURL: 'downloader:target.url',\n cookie: 'downloader:cookie',\n useStatusCache: 'downloader:use.status.cache',\n stopOn: 'downloader:stop.on',\n noPrompt: 'downloader:no.prompt',\n pathToFFmpeg: 'downloader:path.to.ffmpeg',\n dryRun: 'downloader:dry.run',\n outDir: 'output:out.dir',\n dirNameFormat: {\n campaign: 'output:campaign.dir.name.format',\n content: 'output:content.dir.name.format'\n },\n filenameFormat: {\n media: 'output:media.filename.format'\n },\n fileExistsAction: {\n content: 'output:content.file.exists.action',\n info: 'output:info.file.exists.action',\n infoAPI: 'output:info.api.file.exists.action'\n },\n include: {\n lockedContent: 'include:locked.content',\n postsWithMediaType: 'include:posts.with.media.type',\n postsInTier: 'include:posts.in.tier',\n postsPublishedAfter: 'include:posts.published.after',\n postsPublishedBefore: 'include:posts.published.before',\n campaignInfo: 'include:campaign.info',\n contentInfo: 'include:content.info',\n previewMedia: 'include:preview.media',\n contentMedia: 'include:content.media',\n allMediaVariants: 'include:all.media.variants',\n imagesByFilename: 'include:images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include:attachments.by.filename',\n comments: 'include:comments'\n },\n request: {\n maxRetries: 'request:max.retries',\n maxConcurrent: 'request:max.concurrent',\n minTime: 'request:min.time',\n proxy: {\n url: 'request:proxy.url',\n rejectUnauthorizedTLS: 'request:proxy.reject.unauthorized.tls'\n }\n },\n consoleLogger: {\n enabled: 'logger.console:enabled',\n logLevel: 'logger.console:log.level',\n include: {\n dateTime: 'logger.console:include.date.time',\n level: 'logger.console:include.level',\n originator: 'logger.console:include.originator',\n errorStack: 'logger.console:include.error.stack'\n },\n dateTimeFormat: 'logger.console:date.time.format',\n color: 'logger.console:color'\n },\n fileLogger: {\n enabled: ':enabled',\n logDir: ':log.dir',\n logFilename: ':log.filename',\n fileExistsAction: ':file.exists.action',\n logLevel: ':log.level',\n include: {\n dateTime: ':include.date.time',\n level: ':include.level',\n originator: ':include.originator',\n errorStack: ':include.error.stack'\n },\n dateTimeFormat: ':date.time.format',\n color: ':color'\n },\n embedDownloader: {\n exec: ':exec'\n }\n};\n\nexport type ConfigFileParseResult = RecursivePropsTo<DeepPartial<Omit<CLIOptions, 'targetURLs'>>, CLIOptionParserEntry> & {\n targetURLs?: CLIOptionParserEntry;\n};\n\nexport default class ConfigFileParser {\n\n static parse(file: string): ConfigFileParseResult {\n const parser = new ConfigParser();\n\n parser.read(file);\n\n const __getValue = (prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, prop);\n };\n\n return {\n targetURLs: __getValue(CONFIG_FILE_PROPS.targetURL),\n cookie: __getValue(CONFIG_FILE_PROPS.cookie),\n useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),\n stopOn: __getValue(CONFIG_FILE_PROPS.stopOn),\n pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),\n outDir: __getValue(CONFIG_FILE_PROPS.outDir),\n dirNameFormat: {\n campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),\n content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)\n },\n filenameFormat: {\n media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)\n },\n include: {\n lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),\n postsWithMediaType: __getValue(CONFIG_FILE_PROPS.include.postsWithMediaType),\n postsInTier: __getValue(CONFIG_FILE_PROPS.include.postsInTier),\n postsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.postsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.postsPublishedBefore),\n },\n campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),\n contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),\n previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),\n contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),\n allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants),\n mediaByFilename: {\n images: __getValue(CONFIG_FILE_PROPS.include.imagesByFilename),\n audio: __getValue(CONFIG_FILE_PROPS.include.audioByFilename),\n attachments: __getValue(CONFIG_FILE_PROPS.include.attachmentsByFilename)\n },\n comments: __getValue(CONFIG_FILE_PROPS.include.comments)\n },\n request: {\n maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),\n maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),\n minTime: __getValue(CONFIG_FILE_PROPS.request.minTime),\n proxy: {\n url: __getValue(CONFIG_FILE_PROPS.request.proxy.url),\n rejectUnauthorizedTLS: __getValue(CONFIG_FILE_PROPS.request.proxy.rejectUnauthorizedTLS),\n }\n },\n fileExistsAction: {\n content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),\n info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),\n infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)\n },\n noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),\n dryRun: __getValue(CONFIG_FILE_PROPS.dryRun),\n consoleLogger: {\n enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),\n logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),\n include: {\n dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),\n level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),\n originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),\n errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),\n color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)\n },\n fileLoggers: this.#parseFileLoggerOptions(parser),\n embedDownloaders: this.#parseEmbedDownloaderOptions(parser)\n };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key, true)?.trim();\n if (value && value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1);\n }\n if (value) {\n return {\n src: 'cfg',\n section,\n key,\n value\n };\n }\n return undefined;\n }\n\n static #parseFileLoggerOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));\n\n const loggers = sections.reduce<NonNullable<ConfigFileParseResult['fileLoggers']>>((result, section) => {\n result.push({\n enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),\n logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),\n logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),\n fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),\n logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),\n include: {\n dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),\n level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),\n originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),\n errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),\n color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)\n });\n return result;\n }, []);\n\n return loggers.length > 0 ? loggers : undefined;\n }\n\n static #parseEmbedDownloaderOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('embed.downloader.'));\n const prefixLength = 'embed.downloader.'.length;\n const embedDownloaders = sections.reduce<NonNullable<ConfigFileParseResult['embedDownloaders']>>((result, section) => {\n const provider = section.substring(prefixLength).trim().toLowerCase();\n if (!provider) {\n throw Error('Config file section \\'embed.downloader.<provider>\\' is missing the provider name');\n }\n if (result.find((dl) => dl.provider?.value === provider)) {\n throw Error(`Duplicate config file section 'embed.downloader.${provider}`);\n }\n const exec = __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec);\n if (exec) {\n result.push({\n provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },\n exec\n });\n }\n return result;\n }, []);\n\n return embedDownloaders.length > 0 ? embedDownloaders : undefined;\n }\n}\n"]}
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,OAAO,OAAO,oBAAoB;;;IAiBjC,KAAK;IA0XL,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;CAMzB"}
|