patreon-dl 1.5.0 → 1.6.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.
Files changed (46) hide show
  1. package/README.md +41 -2
  2. package/bin/patreon-dl-vimeo.js +140 -0
  3. package/dist/cli/CLIOptions.d.ts.map +1 -1
  4. package/dist/cli/CLIOptions.js +10 -0
  5. package/dist/cli/CLIOptions.js.map +1 -1
  6. package/dist/cli/ConfigFileParser.d.ts.map +1 -1
  7. package/dist/cli/ConfigFileParser.js +28 -3
  8. package/dist/cli/ConfigFileParser.js.map +1 -1
  9. package/dist/downloaders/Downloader.d.ts.map +1 -1
  10. package/dist/downloaders/Downloader.js +10 -4
  11. package/dist/downloaders/Downloader.js.map +1 -1
  12. package/dist/downloaders/DownloaderOptions.d.ts +6 -1
  13. package/dist/downloaders/DownloaderOptions.d.ts.map +1 -1
  14. package/dist/downloaders/DownloaderOptions.js +4 -2
  15. package/dist/downloaders/DownloaderOptions.js.map +1 -1
  16. package/dist/downloaders/PostDownloader.d.ts.map +1 -1
  17. package/dist/downloaders/PostDownloader.js +10 -7
  18. package/dist/downloaders/PostDownloader.js.map +1 -1
  19. package/dist/downloaders/index.d.ts +1 -1
  20. package/dist/downloaders/index.d.ts.map +1 -1
  21. package/dist/downloaders/index.js.map +1 -1
  22. package/dist/downloaders/task/DownloadTaskFactory.d.ts +3 -1
  23. package/dist/downloaders/task/DownloadTaskFactory.d.ts.map +1 -1
  24. package/dist/downloaders/task/DownloadTaskFactory.js +18 -3
  25. package/dist/downloaders/task/DownloadTaskFactory.js.map +1 -1
  26. package/dist/downloaders/task/ExternalDownloaderTask.d.ts +22 -0
  27. package/dist/downloaders/task/ExternalDownloaderTask.d.ts.map +1 -0
  28. package/dist/downloaders/task/ExternalDownloaderTask.js +197 -0
  29. package/dist/downloaders/task/ExternalDownloaderTask.js.map +1 -0
  30. package/dist/entities/Downloadable.d.ts +2 -1
  31. package/dist/entities/Downloadable.d.ts.map +1 -1
  32. package/dist/entities/Downloadable.js +3 -0
  33. package/dist/entities/Downloadable.js.map +1 -1
  34. package/dist/entities/Post.d.ts +1 -0
  35. package/dist/entities/Post.d.ts.map +1 -1
  36. package/dist/entities/Post.js.map +1 -1
  37. package/dist/parsers/PostParser.d.ts.map +1 -1
  38. package/dist/parsers/PostParser.js +1 -0
  39. package/dist/parsers/PostParser.js.map +1 -1
  40. package/dist/utils/Formatter.js +1 -1
  41. package/dist/utils/Formatter.js.map +1 -1
  42. package/dist/utils/URLHelper.d.ts +1 -0
  43. package/dist/utils/URLHelper.d.ts.map +1 -1
  44. package/dist/utils/URLHelper.js +10 -0
  45. package/dist/utils/URLHelper.js.map +1 -1
  46. package/package.json +6 -2
package/README.md CHANGED
@@ -13,6 +13,9 @@ A Patreon downloader written in [Node.js](https://nodejs.org).
13
13
  - images
14
14
  - audio
15
15
  - attachments
16
+ - embedded videos
17
+ - YouTube downloader built-in
18
+ - Supports [external downloader](#embedded-videos---external-downloader)
16
19
  - Save campaign and content info
17
20
  - Extensively configurable
18
21
 
@@ -20,8 +23,7 @@ You can run `patreon-dl` from the command-line or use it as a library for your p
20
23
 
21
24
  ### Limitations
22
25
 
23
- - Embedded videos, other than those from YouTube, are not supported (e.g. Vimeo). Only info about these embeds is saved.
24
- - Likewise, embedded links are not followed; only info about the embed is saved.
26
+ - Embedded links are not followed; only info about the embed is saved.
25
27
 
26
28
  ### FFmpeg dependency
27
29
 
@@ -41,6 +43,14 @@ $ patreon-dl --configure-youtube
41
43
 
42
44
  For library usage, see [Configuring YouTube connection](#configuring-youtube-connection).
43
45
 
46
+ > ...or you may just refer to the next section on how to download enhanecd-quality videos without a Premium account.
47
+
48
+ ### Embedded videos - external downloader
49
+
50
+ You can specify external programs to download embedded videos. For YouTube videos, this will replace the built-in downloader. See the [example config](./example-embed.conf) on how to do this. For library usage, see [External downloaders](#external-downloaders).
51
+
52
+ > The example config utilizes [yt-dlp](https://github.com/yt-dlp/yt-dlp), a popular program capable of downloading YouTube and Vimeo content. As of current release, `yt-dlp` is also able to download Premium-quality YouTube videos without a Premium account.
53
+
44
54
  ## Installation
45
55
 
46
56
  1. First, install [Node.js](https://nodejs.org).
@@ -237,6 +247,7 @@ An object with the following properties (all *optional*):
237
247
  | `include` | What to include in the download: (object) <ul><li>`lockedContent`: whether to process locked content. Default: `true`</li><li>`postInTier`: see [Filtering posts by tier](#filtering-posts-by-tier)</li><li>`postsWithMediaType`: sets the media type criteria for downloading posts. Values can be:<ul><li>`any`: download posts regardless of the type of media they contain. Also applies to posts that do not contain any media.</li><li>`none`: only download posts that do not contain media.</li><li>Array<`image` \| `video` \| `audio` \| `attachment`>: only download posts that contain the specified media type(s).</li></ul>Default: `any`</li><li>`campaignInfo`: whether to save campaign info. Default: `true`</li><li>`contentInfo`: whether to save content info. Default: `true`</li><li>`contentMedia`: the type of content media to download (images, videos, audio, attachments, excluding previews). Values can be:<ul><li>`true`: download all content media.</li><li>`false`: do not download content media.</li><li>Array<`image` \| `video` \| `audio` \| `attachment` \| `file`>: only download the specified media type(s).</li></ul>Default: `true`</li><li>`previewMedia`: the type of preview media to download, if available. Values can be:<ul><li>`true`: download all preview media.</li><li>`false`: do not download preview media.</li><li>Array<`image` \| `video` \| `audio`>: only download the specified media type(s).</li></ul>Default: `true`</li><li>`allMediaVariants`: whether to download all media variants, if available. If `false`, only the best quality variant will be downloaded. Default: `false`</li></ul> |
238
248
  | `request` | Rate limiting and retry on error: (object)<ul><li>`maxRetries`: maximum number of retries if a request or download fails. Default: 3</li><li>`maxConcurrent`: maximum number of concurrent downloads. Default: 10</li><li>`minTime`: minimum time to wait between starting requests or downloads (milliseconds). Default: 333</li></ul> |
239
249
  | `fileExistsAction` | What to do when a target file already exists: (object)<ul><li>`info`: in the context of saving info (such as campaign or post info), the action to take when a file belonging to the info already exists. Default: `saveAsCopyIfNewer`</li><li>`infoAPI`: API data is saved as part of info. Because it changes frequently, and usually used for debugging purpose only, you can set a different action when saving an API data file that already exists. Default: `overwrite`</li><li>`content`: in the context of downloading content, the action to take when a file belonging to the content already exists. Default: `skip`</li></ul><p>Supported actions:<ul><li>`overwrite`: overwrite existing file.</li><li>`skip`: skip saving the file.</li><li>`saveAsCopy`: save the file under incremented filename (e.g. "abc.jpg" becomes "abc (1).jpg").</li><li>`saveAsCopyIfNewer`: like `saveAsCopy`, but only do so if the contents have actually changed.</li></ul></p> |
250
+ | `embedDownloaders` | External downloader for embedded videos. See [External downloaders](#external-downloaders).|
240
251
  |`logger` | See [Logger](#logger) |
241
252
 
242
253
  #### Campaign directory name format
@@ -330,6 +341,31 @@ tiers.forEach((tier) => {
330
341
  ```
331
342
  See [Campaign](./docs/api/interfaces/Campaign.md), [Reward](./docs/api/interfaces/Reward.md).
332
343
 
344
+ #### External downloaders
345
+
346
+ You can specify external downloaders for embedded videos. Each entry in the `embedDownloaders` option is an object with the following properties:
347
+
348
+ | Proprety | Description |
349
+ |----------|-------------|
350
+ | `provider` | Name of the provider of embedded content. E.g. `youtube`, `vimeo` (case-insensitive) |
351
+ | `exec` | The command to run to download the embedded content |
352
+
353
+ `exec` can contain fields enclosed in curly braces. They will be replaced with actual values at runtime:
354
+
355
+ | Field | Description |
356
+ |-----------------------|-------------|
357
+ | `post.id` | ID of the post containing the embedded video |
358
+ | `embed.provider` | Name of the provider |
359
+ | `embed.provider.url` | Link to the provider's site |
360
+ | `embed.url` | Link to the video page supplied by the provider |
361
+ | `embed.subject` | Subject of the video |
362
+ | `embed.html` | The HTML code that embeds the video player on the Patreon page |
363
+ | `dest.dir` | The directory where the video should be saved |
364
+
365
+ For example usage of `exec`, see [example-embed.conf](./example-embed.conf).
366
+
367
+ > External downloaders are not subject to `request.maxRetries` and `fileExistsAction` settings. This is because `patreon-dl` has no control over the downloading process nor knowledge about the outcome of it (including where and under what name the file was saved).
368
+
333
369
 
334
370
  ### Configuring YouTube connection
335
371
 
@@ -605,6 +641,9 @@ Each event emitted by a download task batch has a payload, which is an object wi
605
641
 
606
642
  ## Changelog
607
643
 
644
+ v1.6.0
645
+ - Add external downloader support for embedded videos
646
+
608
647
  v1.5.0
609
648
  - Add support for fetching by user ID instead of creator vanity ([#18](https://github.com/patrickkfkan/patreon-dl/issues/18)):
610
649
  - Support URL format `https://www.patreon.com/user/posts?u=<user_id>`
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * External downloader for embedded Vimeo videos. Obtains the appropriate URL to download from and
5
+ * passes it to 'yt-dlp' (https://github.com/yt-dlp/yt-dlp).
6
+ *
7
+ * Usage
8
+ * -----
9
+ * Place the following two lines in your 'patreon-dl' config file:
10
+ *
11
+ * [embed.downloader.vimeo]
12
+ * exec = patreon-dl-vimeo -o "{dest.dir}/%(title)s.%(ext)s" --embed-html "{embed.html}" --embed-url "{embed.url}"
13
+ *
14
+ * You can append the following additional options to the exec line if necessary:
15
+ * --video-password "<password>": for password-protected videos
16
+ * --yt-dlp "</path/to/yt-dlp>": if yt-dlp is not in the PATH
17
+ *
18
+ * Upon encountering a post with embedded Vimeo content, 'patreon-dl' will call this script. The following then happens:
19
+ * - This script obtains the video URL from 'embed.html' or 'embed.url'.
20
+ * - The URL is passed to yt-dlp.
21
+ * - yt-dlp downloads the video from URL and saves it to 'dest.dir'. The filename is determined by the specified
22
+ * format '%(title)s.%(ext)s' (see: https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#output-template).
23
+ *
24
+ */
25
+
26
+ import parseArgs from 'yargs-parser';
27
+ import spawn from '@patrickkfkan/cross-spawn';
28
+ import path from 'path';
29
+
30
+ function tryGetPlayerURL(html) {
31
+ if (!html) {
32
+ return null;
33
+ }
34
+ const regex = /https:\/\/player\.vimeo\.com\/video\/\d+/g;
35
+ const match = regex.exec(html);
36
+ if (match && match[0]) {
37
+ return match[0];
38
+ }
39
+ return null;
40
+ }
41
+
42
+ function getCommandString(cmd, args) {
43
+ const quotedArgs = args.map((arg) => arg.includes(' ') ? `"${arg}"` : arg);
44
+ return [
45
+ cmd,
46
+ ...quotedArgs
47
+ ].join(' ');
48
+ }
49
+
50
+ async function download(url, o, videoPassword, ytdlpPath) {
51
+ let proc;
52
+ const ytdlp = ytdlpPath || 'yt-dlp';
53
+ try {
54
+ return await new Promise((resolve, reject) => {
55
+ let settled = false;
56
+ const args = [
57
+ '-f',
58
+ 'bv*+ba[acodec^=mp4a]',
59
+ '-o',
60
+ o
61
+ ];
62
+ const printArgs = [...args];
63
+ if (videoPassword) {
64
+ args.push('--video-password', videoPassword);
65
+ printArgs.push('--video-password', '******');
66
+ }
67
+ args.push(url);
68
+ printArgs.push(url);
69
+
70
+ console.log(`Command: ${getCommandString(ytdlp, printArgs)}`);
71
+ proc = spawn(ytdlp, args);
72
+
73
+ proc.stdout?.on('data', (data) => {
74
+ console.log(data.toString());
75
+ });
76
+
77
+ proc.stderr?.on('data', (data_1) => {
78
+ console.error(data_1.toString());
79
+ });
80
+
81
+ proc.on('error', (err) => {
82
+ if (settled) {
83
+ return;
84
+ }
85
+ settled = true;
86
+ reject(err);
87
+ });
88
+
89
+ proc.on('exit', (code) => {
90
+ if (settled) {
91
+ return;
92
+ }
93
+ settled = true;
94
+ resolve(code);
95
+ });
96
+ });
97
+ } finally {
98
+ if (proc) {
99
+ proc.removeAllListeners();
100
+ proc.stdout?.removeAllListeners();
101
+ proc.stderr?.removeAllListeners();
102
+ }
103
+ }
104
+ }
105
+
106
+ const args = parseArgs(process.argv.slice(2));
107
+ const {
108
+ 'o': _o,
109
+ 'embed-html': _embedHTML,
110
+ 'embed-url': _embedURL,
111
+ 'video-password': videoPassword,
112
+ 'yt-dlp': _ytdlpPath
113
+ } = args;
114
+ const o = _o?.trim() ? path.resolve(_o.trim()) : null;
115
+ const embedHTML = _embedHTML?.trim();
116
+ const embedURL = _embedURL?.trim();
117
+ const ytdlpPath = _ytdlpPath?.trim() ? path.resolve(_ytdlpPath.trim()) : null;
118
+
119
+ if (!o) {
120
+ console.error('No output file specified');
121
+ process.exit(1);
122
+ }
123
+
124
+ if (!embedHTML && !embedURL) {
125
+ console.error('No embed HTML or URL provided');
126
+ process.exit(1);
127
+ }
128
+
129
+ const url = tryGetPlayerURL(embedHTML) || embedURL;
130
+
131
+ if (!url) {
132
+ console.error(`Failed to obtain video URL`);
133
+ process.exit(1);
134
+ }
135
+
136
+ console.log(`Going to download video from "${url}"`);
137
+
138
+ download(url, o, videoPassword, ytdlpPath).then((code) => {
139
+ process.exit(code);
140
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"CLIOptions.d.ts","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAElG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAA0B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,gBAA2C,MAAM,uBAAuB,CAAC;AAGhF,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,CAA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U,CAkD1C;AAED,wBAAgB,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;;;;;;;;;;;;;;EAsCvJ"}
@@ -43,6 +43,7 @@ export function getCLIOptions() {
43
43
  info: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.info, configFileOptions?.fileExistsAction?.info), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),
44
44
  infoAPI: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.infoAPI, configFileOptions?.fileExistsAction?.infoAPI), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer')
45
45
  },
46
+ embedDownloaders: getEmbedDownloaderOptions(configFileOptions),
46
47
  noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,
47
48
  consoleLogger,
48
49
  fileLoggers
@@ -103,6 +104,15 @@ function getCLIIncludeOptions(commandLineOptions, configFileOptions) {
103
104
  allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants))
104
105
  };
105
106
  }
107
+ function getEmbedDownloaderOptions(configFileOptions) {
108
+ if (configFileOptions?.embedDownloaders) {
109
+ return configFileOptions?.embedDownloaders.map((dl) => ({
110
+ provider: CLIOptionValidator.validateRequired(dl.provider),
111
+ exec: CLIOptionValidator.validateRequired(dl.exec)
112
+ }));
113
+ }
114
+ return undefined;
115
+ }
106
116
  function readTargetsFile(file) {
107
117
  const includeKeys = {
108
118
  lockedContent: 'include.locked.content',
@@ -1 +1 @@
1
- {"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,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derOptions } from '../downloaders/DownloaderOptions.js';\nimport { pickDefined } from '../utils/Misc.js';\nimport { ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\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 noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || 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 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 };\n}\n\nfunction readTargetsFile(file: string) {\n const includeKeys: Record<keyof DownloaderIncludeOptions, string> = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\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 };\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?: Partial<Record<keyof 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 if (!target.include) {\n target.include = {};\n }\n target.include[optName as keyof DownloaderIncludeOptions] = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error) {\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 v.include = getCLIIncludeOptions(target);\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,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,iBAA6C,MAAM,wBAAwB,CAAC;AACnF,OAAO,gBAA2C,MAAM,uBAAuB,CAAC;AAChF,OAAO,IAAI,MAAM,MAAM,CAAC;AA4BxB,MAAM,UAAU,aAAa;IAC3B,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,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oBAAoB,CAAC,MAAM,CAAC,CAAC;SAC1C;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAChB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\nimport { DownloaderIncludeOptions, DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { pickDefined } from '../utils/Misc.js';\nimport { ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\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 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 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 };\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: Record<keyof DownloaderIncludeOptions, string> = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\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 };\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?: Partial<Record<keyof 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 if (!target.include) {\n target.include = {};\n }\n target.include[optName as keyof DownloaderIncludeOptions] = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error) {\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 v.include = getCLIIncludeOptions(target);\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,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAiEjE,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;CAwGlD"}
1
+ {"version":3,"file":"ConfigFileParser.d.ts","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAoEjE,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;CAkIlD"}
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _a, _ConfigFileParser_getValueFromConfigParser, _ConfigFileParser_parseFileLoggerOptions;
6
+ var _a, _ConfigFileParser_getValueFromConfigParser, _ConfigFileParser_parseFileLoggerOptions, _ConfigFileParser_parseEmbedDownloaderOptions;
7
7
  import ConfigParser from 'configparser';
8
8
  const CONFIG_FILE_PROPS = {
9
9
  targetURL: 'downloader:target.url',
@@ -65,6 +65,9 @@ const CONFIG_FILE_PROPS = {
65
65
  },
66
66
  dateTimeFormat: ':date.time.format',
67
67
  color: ':color'
68
+ },
69
+ embedDownloader: {
70
+ exec: ':exec'
68
71
  }
69
72
  };
70
73
  export default class ConfigFileParser {
@@ -120,13 +123,14 @@ export default class ConfigFileParser {
120
123
  dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),
121
124
  color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)
122
125
  },
123
- fileLoggers: __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_parseFileLoggerOptions).call(this, parser)
126
+ fileLoggers: __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_parseFileLoggerOptions).call(this, parser),
127
+ embedDownloaders: __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_parseEmbedDownloaderOptions).call(this, parser)
124
128
  };
125
129
  }
126
130
  }
127
131
  _a = ConfigFileParser, _ConfigFileParser_getValueFromConfigParser = function _ConfigFileParser_getValueFromConfigParser(parser, prop) {
128
132
  const [section, key] = prop.split(':');
129
- let value = parser.get(section, key)?.trim();
133
+ let value = parser.get(section, key, true)?.trim();
130
134
  if (value && value.startsWith('"') && value.endsWith('"')) {
131
135
  value = value.substring(1, value.length - 1);
132
136
  }
@@ -163,5 +167,26 @@ _a = ConfigFileParser, _ConfigFileParser_getValueFromConfigParser = function _Co
163
167
  return result;
164
168
  }, []);
165
169
  return loggers.length > 0 ? loggers : undefined;
170
+ }, _ConfigFileParser_parseEmbedDownloaderOptions = function _ConfigFileParser_parseEmbedDownloaderOptions(parser) {
171
+ const __getValue = (section, prop) => {
172
+ return __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_getValueFromConfigParser).call(this, parser, `${section}${prop}`);
173
+ };
174
+ const sections = parser.sections().filter((section) => section.startsWith('embed.downloader.'));
175
+ const prefixLength = 'embed.downloader.'.length;
176
+ const embedDownloaders = sections.reduce((result, section) => {
177
+ const provider = section.substring(prefixLength).trim().toLowerCase();
178
+ if (!provider) {
179
+ throw Error('Config file section \'embed.downloader.<provider>\' is missing the provider name');
180
+ }
181
+ if (result.find((dl) => dl.provider?.value === provider)) {
182
+ throw Error(`Duplicate config file section 'embed.downloader.${provider}`);
183
+ }
184
+ result.push({
185
+ provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },
186
+ exec: __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec)
187
+ });
188
+ return result;
189
+ }, []);
190
+ return embedDownloaders.length > 0 ? embedDownloaders : undefined;
166
191
  };
167
192
  //# sourceMappingURL=ConfigFileParser.js.map
@@ -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,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,w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B,CAAC,UAAU,CAAC,WAAW,CAAC;YAC1E,gBAAgB,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACpF,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC;YACpE,OAAO,EAAE;gBACP,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC5E,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtE,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;gBAChF,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;aACjF;YACD,cAAc,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,cAAc,CAAC;YAChF,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC;SAC/D,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC","sourcesContent":["import ConfigParser from 'configparser';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { DeepPartial, 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 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 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 },\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};\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 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 },\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 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 };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key)?.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"]}
1
+ {"version":3,"file":"ConfigFileParser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AAmD,QAAQ,EAAE,CAAC,CAAC;SAC5E;QACD,MAAM,CAAC,IAAI,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","sourcesContent":["import ConfigParser from 'configparser';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { DeepPartial, 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 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 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 },\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 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 },\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 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 +1 @@
1
- {"version":3,"file":"Downloader.d.ts","sourceRoot":"","sources":["../../src/downloaders/Downloader.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAkB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAqB,MAAM,wBAAwB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAa,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQ3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,cAAc,IACnD,cAAc,GACd,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,UAAU,wBAAwB;IAChC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,gBAAgB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E,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAKpG,IAAI,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAKtG,GAAG,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAKrG,IAAI,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,OAAO;CAItF"}
@@ -28,6 +28,7 @@ import { AbortError } from 'node-fetch';
28
28
  import ffmpeg from 'fluent-ffmpeg';
29
29
  import InnertubeLoader from '../utils/InnertubeLoader.js';
30
30
  import FFmpegDownloadTaskBase from './task/FFmpegDownloadTaskBase.js';
31
+ import ExternalDownloaderTask from './task/ExternalDownloaderTask.js';
31
32
  export default class Downloader extends EventEmitter {
32
33
  constructor(bootstrap, options) {
33
34
  super();
@@ -64,19 +65,23 @@ export default class Downloader extends EventEmitter {
64
65
  });
65
66
  batch.on('taskStart', ({ task }) => {
66
67
  const retryOrBeginStr = task.retryCount > 0 ? 'retry' : 'begin';
67
- this.log('info', `Download ${retryOrBeginStr} (${__getDownloadIdString(task, batch)}): [type: ${task.srcEntity.type}; ID: #${task.srcEntity.id}] -> ${task.resolvedDestFilename}`);
68
+ const isExternal = task instanceof ExternalDownloaderTask;
69
+ const destStr = isExternal ? ' -> Unknown destination (external process)' : task.resolvedDestFilename ? ` -> ${task.resolvedDestFilename}` : '';
70
+ this.log('info', `Download ${retryOrBeginStr} (${__getDownloadIdString(task, batch)}): [type: ${task.srcEntity.type}; ID: #${task.srcEntity.id}]${destStr}`);
68
71
  if (task instanceof FFmpegDownloadTaskBase) {
69
72
  const retryOrBeginStr = task.retryCount > 0 ? 'Retry' : 'Begin';
70
73
  this.log('info', `${retryOrBeginStr} downloading through FFmpeg (${__getDownloadIdString(task, batch)}): ${task.commandLine}`);
71
74
  }
72
75
  });
73
76
  batch.on('taskComplete', ({ task }) => {
74
- this.log('info', `Download complete (${__getDownloadIdString(task, batch)}): "${task.resolvedDestPath}"`);
77
+ const isExternal = task instanceof ExternalDownloaderTask;
78
+ const destStr = isExternal ? ': Unknown destination (external process)' : task.resolvedDestPath ? `: "${task.resolvedDestPath}"` : '';
79
+ this.log('info', `Download complete (${__getDownloadIdString(task, batch)})${destStr}`);
75
80
  });
76
81
  batch.on('taskError', ({ error, willRetry }) => {
77
- const { task, cause } = error;
82
+ const { task, cause, message } = error;
78
83
  const retryStr = willRetry ? '- will retry' : '';
79
- this.log('error', `Download error (${__getDownloadIdString(task, batch)}):`, cause, `(${task.src})`, retryStr);
84
+ this.log('error', `Download error (${__getDownloadIdString(task, batch)}):`, cause || message, `(${task.src})`, retryStr);
80
85
  });
81
86
  batch.on('taskAbort', ({ task }) => {
82
87
  this.log('warn', `Download aborted (${__getDownloadIdString(task, batch)})`);
@@ -123,6 +128,7 @@ export default class Downloader extends EventEmitter {
123
128
  item: tt,
124
129
  destDir,
125
130
  fetcher: this.fetcher,
131
+ embedDownloaders: this.config.embedDownloaders,
126
132
  destFilenameFormat: this.config.filenameFormat.media,
127
133
  fileExistsAction: task.fileExistsAction,
128
134
  maxRetries: this.config.request.maxRetries,