patreon-dl 1.1.1 → 1.2.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 (63) hide show
  1. package/README.md +9 -3
  2. package/dist/cli/CLIOptionValidator.d.ts +4 -0
  3. package/dist/cli/CLIOptionValidator.d.ts.map +1 -1
  4. package/dist/cli/CLIOptionValidator.js +46 -0
  5. package/dist/cli/CLIOptionValidator.js.map +1 -1
  6. package/dist/cli/CLIOptions.js +5 -6
  7. package/dist/cli/CLIOptions.js.map +1 -1
  8. package/dist/cli/CommandLineParser.d.ts.map +1 -1
  9. package/dist/cli/CommandLineParser.js +2 -0
  10. package/dist/cli/CommandLineParser.js.map +1 -1
  11. package/dist/cli/ConfigFileParser.d.ts.map +1 -1
  12. package/dist/cli/ConfigFileParser.js +2 -0
  13. package/dist/cli/ConfigFileParser.js.map +1 -1
  14. package/dist/downloaders/Bootstrap.d.ts +4 -2
  15. package/dist/downloaders/Bootstrap.d.ts.map +1 -1
  16. package/dist/downloaders/Bootstrap.js.map +1 -1
  17. package/dist/downloaders/Downloader.d.ts +1 -1
  18. package/dist/downloaders/Downloader.d.ts.map +1 -1
  19. package/dist/downloaders/Downloader.js +7 -5
  20. package/dist/downloaders/Downloader.js.map +1 -1
  21. package/dist/downloaders/DownloaderEvent.d.ts +2 -1
  22. package/dist/downloaders/DownloaderEvent.d.ts.map +1 -1
  23. package/dist/downloaders/DownloaderEvent.js +1 -0
  24. package/dist/downloaders/DownloaderEvent.js.map +1 -1
  25. package/dist/downloaders/DownloaderOptions.d.ts +3 -2
  26. package/dist/downloaders/DownloaderOptions.d.ts.map +1 -1
  27. package/dist/downloaders/DownloaderOptions.js +2 -0
  28. package/dist/downloaders/DownloaderOptions.js.map +1 -1
  29. package/dist/downloaders/PostDownloader.d.ts +2 -1
  30. package/dist/downloaders/PostDownloader.d.ts.map +1 -1
  31. package/dist/downloaders/PostDownloader.js +62 -10
  32. package/dist/downloaders/PostDownloader.js.map +1 -1
  33. package/dist/downloaders/ProductDownloader.d.ts +2 -1
  34. package/dist/downloaders/ProductDownloader.d.ts.map +1 -1
  35. package/dist/downloaders/ProductDownloader.js +19 -8
  36. package/dist/downloaders/ProductDownloader.js.map +1 -1
  37. package/dist/downloaders/cache/StatusCache.d.ts +2 -2
  38. package/dist/downloaders/cache/StatusCache.d.ts.map +1 -1
  39. package/dist/downloaders/cache/StatusCache.js +17 -5
  40. package/dist/downloaders/cache/StatusCache.js.map +1 -1
  41. package/dist/downloaders/task/FFmpegDownloadTaskBase.d.ts +1 -1
  42. package/dist/downloaders/task/FFmpegDownloadTaskBase.d.ts.map +1 -1
  43. package/dist/downloaders/task/FFmpegDownloadTaskBase.js +1 -1
  44. package/dist/downloaders/task/FFmpegDownloadTaskBase.js.map +1 -1
  45. package/dist/downloaders/task/M3U8DownloadTask.d.ts +1 -1
  46. package/dist/downloaders/task/M3U8DownloadTask.d.ts.map +1 -1
  47. package/dist/downloaders/task/M3U8DownloadTask.js.map +1 -1
  48. package/dist/downloaders/task/YouTubeDownloadTask.d.ts +1 -1
  49. package/dist/downloaders/task/YouTubeDownloadTask.d.ts.map +1 -1
  50. package/dist/downloaders/task/YouTubeDownloadTask.js.map +1 -1
  51. package/dist/utils/FSHelper.d.ts +2 -2
  52. package/dist/utils/FSHelper.d.ts.map +1 -1
  53. package/dist/utils/FSHelper.js.map +1 -1
  54. package/dist/utils/Misc.d.ts +3 -3
  55. package/dist/utils/Misc.d.ts.map +1 -1
  56. package/dist/utils/Misc.js.map +1 -1
  57. package/dist/utils/logging/ConsoleLogger.d.ts +12 -1
  58. package/dist/utils/logging/ConsoleLogger.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/dist/downloaders/task/FFmpegDownloadTask.d.ts +0 -27
  61. package/dist/downloaders/task/FFmpegDownloadTask.d.ts.map +0 -1
  62. package/dist/downloaders/task/FFmpegDownloadTask.js +0 -206
  63. package/dist/downloaders/task/FFmpegDownloadTask.js.map +0 -1
package/README.md CHANGED
@@ -148,9 +148,9 @@ An object with the following properties (all *optional*):
148
148
  | `outDir` | Path to directory where content is saved. Default: current working directory |
149
149
  | `dirNameFormat` | How to name directories: (object)<ul><li>`campaign`: see [Campaign directory name format](#campaign-directory-name-format)</li><li>`content`: see [Content directory name format](#content-directory-name-format)</li></ul> |
150
150
  | `filenameFormat` | Naming of files: (object)<ul><li>`media`: see [Media filename format](#media-filename-format) |
151
- | `include` | What to include in the download: (object) <ul><li>`lockedContent`: whether to process locked content. Default: `true`</li><li>`campaignInfo`: whether to save campaign info. Default: `true`</li><li>`contentInfo`: whether to save content info. Default: `true`</li><li>`contentMedia`: whether to download content media (images, videos, audio, attachments, excluding previews). Default: `true`</li><li>`previewMedia`: whether to download preview media, if available. 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> |
151
+ | `include` | What to include in the download: (object) <ul><li>`lockedContent`: whether to process locked content. Default: `true`</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> |
152
152
  | `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> |
153
- | `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:<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> |
153
+ | `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> |
154
154
  |`logger` | See [Logger](#logger) |
155
155
 
156
156
  #### Campaign directory name format
@@ -443,7 +443,7 @@ Each event emitted by a `PatreonDownloader` instance has a payload, which is an
443
443
  |---------------|-----------------------------------------------|
444
444
  | `fetchBegin` | <p>Emitted when downloader begins fetching data about target(s).<p><p>Payload properties:<ul><li>`targetType`: the type of target being fetched; one of `product`, `post` or `post`.</li></ul></p> |
445
445
  | `targetBegin` | <p>Emitted when downloader begins processing a target.</p><p>Payload properties:<ul><li>`target`: the target being processed; one of [Campaign](./docs/api/interfaces/Campaign.md), [Product](./docs/api/interfaces/Product.md) or [Post](./docs/api/interfaces/Post.md).</li></ul></p> |
446
- | `targetEnd` | <p>Emitted when downloader is done processing a target.</p><p>Payload properties:<ul><li>`target`: the target processed; one of [Campaign](./docs/api/interfaces/Campaign.md), [Product](./docs/api/interfaces/Product.md) or [Post](./docs/api/interfaces/Post.md).</li><li>`isSkipped`: whether target was skipped.</li></ul></p><p>If `isSkipped` is `true`, the following additional properties are available:<ul><li>`skipReason`: the reason for skipping the target; one of the following enums:<ul><li>`TargetSkipReason.Inaccessible`</li><li>`TargetSkipReason.AlreadyDownloaded`</li></ul></li><li>`skipMessage`: description of the skip reason.</li></ul></p> |
446
+ | `targetEnd` | <p>Emitted when downloader is done processing a target.</p><p>Payload properties:<ul><li>`target`: the target processed; one of [Campaign](./docs/api/interfaces/Campaign.md), [Product](./docs/api/interfaces/Product.md) or [Post](./docs/api/interfaces/Post.md).</li><li>`isSkipped`: whether target was skipped.</li></ul></p><p>If `isSkipped` is `true`, the following additional properties are available:<ul><li>`skipReason`: the reason for skipping the target; one of the following enums:<ul><li>`TargetSkipReason.Inaccessible`</li><li>`TargetSkipReason.AlreadyDownloaded`</li><li>`TargetSkipReason.UnmetMediaTypeCriteria`</li></ul></li><li>`skipMessage`: description of the skip reason.</li></ul></p> |
447
447
  | `phaseBegin` | <p>Emitted when downloader begins a phase in the processing of a target.</p><p>Payload properties:<ul><li>`target`: the subject target of the phase; one of [Campaign](./docs/api/interfaces/Campaign.md), [Product](./docs/api/interfaces/Product.md) or [Post](./docs/api/interfaces/Post.md).</li><li>`phase`: the phase that is about to begin; one of `saveInfo` or `batchDownload`.</li></ul></p><p>If `phase` is `batchDownload`, the following additional property is available:<ul><li>`batch`: an object representing the batch of downloads to be executed by the downloader. For monitoring downloads in the batch, see Download Task Batch.</li></ul></p> |
448
448
  | `phaseEnd` | <p>Emitted when a phase ends for a target.</p><p>Payload properties:<ul><li>`target`: the subject target of the phase; one of [Campaign](./docs/api/interfaces/Campaign.md), [Product](./docs/api/interfaces/Product.md) or [Post](./docs/api/interfaces/Post.md).</li><li>`phase`: the phase that has ended; one of `saveInfo` or `batchDownload`.</li></ul></p> |
449
449
  | `end` | <p>Emitted when downloader ends.</p><p>Payload properties:<ul><li>`aborted`: boolean indicating whether the downloader is ending because of an abort request</li><li>`error`: if downloader ends because of an error, then `error` will be the captured error. Note that `error` is not necessarily an `Error` object; it can be anything other than `undefined`.</li></ul></p> |
@@ -494,6 +494,12 @@ Each event emitted by a download task batch has a payload, which is an object wi
494
494
 
495
495
  ## Changelog
496
496
 
497
+ v1.2.0
498
+ - Add support for granular control over:
499
+ - posts to include in download based on type of media contained
500
+ - the type of media to download
501
+ - Bug fixes
502
+
497
503
  v1.1.1
498
504
  - Fix initial data parsing following Patreon changes
499
505
 
@@ -5,5 +5,9 @@ export default class CLIOptionValidator {
5
5
  static validateString<T extends string[]>(entry?: CLIOptionParserEntry, ...match: T): T[number] | undefined;
6
6
  static validateBoolean(entry?: CLIOptionParserEntry): boolean | undefined;
7
7
  static validateNumber(entry?: CLIOptionParserEntry, min?: number, max?: number): number | undefined;
8
+ static validateStringArray<T>(entry: CLIOptionParserEntry | undefined, match: readonly T[], delimiter?: string): T[] | undefined;
9
+ static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry): "none" | "any" | ("attachment" | "audio" | "video" | "image")[] | undefined;
10
+ static validateIncludePreviewMedia(entry?: CLIOptionParserEntry): boolean | ("audio" | "video" | "image")[] | undefined;
11
+ static validateIncludeContentMedia(entry?: CLIOptionParserEntry): boolean | ("attachment" | "file" | "audio" | "video" | "image")[] | undefined;
8
12
  }
9
13
  //# sourceMappingURL=CLIOptionValidator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CLIOptionValidator.d.ts","sourceRoot":"","sources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AAE,oBAAoB,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,SAAM;IAuB3G,MAAM,CAAC,mCAAmC,CAAC,KAAK,CAAC,EAAE,oBAAoB;IASvE,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,oBAAoB;IAS/D,MAAM,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,oBAAoB;CAehE"}
@@ -75,6 +75,52 @@ export default class CLIOptionValidator {
75
75
  }
76
76
  return sanitized;
77
77
  }
78
+ static validateStringArray(entry, match, delimiter = ',') {
79
+ const value = entry?.value || undefined;
80
+ if (!entry || !value) {
81
+ return undefined;
82
+ }
83
+ const split = value.split(delimiter).reduce((result, v) => {
84
+ v = v.trim().toLowerCase();
85
+ if (v && !result.includes(v)) {
86
+ result.push(v);
87
+ }
88
+ return result;
89
+ }, []);
90
+ if (split.length === 0) {
91
+ return undefined;
92
+ }
93
+ for (const v of split) {
94
+ if (!match.includes(v)) {
95
+ throw Error(`${__classPrivateFieldGet(this, _a, "m", _CLIOptionValidator_logEntryKey).call(this, entry)} has invalid delimited value '${v}'; must be one of ${match.map((m) => `'${m}'`).join(', ')}.`);
96
+ }
97
+ }
98
+ return split;
99
+ }
100
+ static validateIncludeContentWithMediaType(entry) {
101
+ try {
102
+ return this.validateString(entry, 'any', 'none');
103
+ }
104
+ catch (error) {
105
+ return this.validateStringArray(entry, ['image', 'video', 'audio', 'attachment']);
106
+ }
107
+ }
108
+ static validateIncludePreviewMedia(entry) {
109
+ try {
110
+ return this.validateBoolean(entry);
111
+ }
112
+ catch (error) {
113
+ return this.validateStringArray(entry, ['image', 'video', 'audio']);
114
+ }
115
+ }
116
+ static validateIncludeContentMedia(entry) {
117
+ try {
118
+ return this.validateBoolean(entry);
119
+ }
120
+ catch (error) {
121
+ return this.validateStringArray(entry, ['image', 'video', 'audio', 'attachment', 'file']);
122
+ }
123
+ }
78
124
  }
79
125
  _a = CLIOptionValidator, _CLIOptionValidator_logEntryKey = function _CLIOptionValidator_logEntryKey(entry) {
80
126
  const keyStr = entry.src === 'cli' ?
@@ -1 +1 @@
1
- {"version":3,"file":"CLIOptionValidator.js","sourceRoot":"","sources":["../../src/cli/CLIOptionValidator.ts"],"names":[],"mappings":";;;;;;AAEA,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,aAAa;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAErC,MAAM,CAAC,gBAAgB,CAAC,KAA4B,EAAE,MAAe;QACnE,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE;YACxB,OAAO,KAAK,CAAC,KAAK,CAAC;SACpB;QACD,IAAI,MAAM,EAAE;YACV,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;SACrB;QACD,IAAI,KAAK,EAAE;YACT,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,mBAAmB,CAAC,CAAC;SAC7D;QACD,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,cAAc,CAAqB,KAA4B,EAAE,GAAG,KAAQ;QACjF,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC;QACvC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACvD,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,mBAAmB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACpG;QACD,OAAO,KAAK,CAAC;I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AE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE;gBACpB,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,wBAAwB,CAAC,CAAC;aAClE;iBACI,IAAI,GAAG,KAAK,SAAS,IAAI,SAAS,GAAG,GAAG,EAAE;gBAC7C,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;aACzE;iBACI,IAAI,GAAG,KAAK,SAAS,IAAI,SAAS,GAAG,GAAG,EAAE;gBAC7C,MAAM,KAAK,CAAC,GAAG,uBAAA,IAAI,2CAAa,MAAjB,IAAI,EAAc,KAAK,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;aAC5E;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAQF;oGANqB,KAA2B;IAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC;QAClC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,KAAK,CAAC,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;IACrC,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,MAAM,GAAG,CAAC;AAChE,CAAC","sourcesContent":["import { CLIOptionParserEntry } from './CLIOptions.js';\n\nconst CLI_OPTION_SRC_NAME = {\n cli: 'Command-line',\n cfg: 'Config 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 #logEntryKey(entry: CLIOptionParserEntry) {\n const keyStr = entry.src === 'cli' ?\n entry.key :\n `[${entry.section}]->${entry.key}`;\n return `${CLI_OPTION_SRC_NAME[entry.src]} option '${keyStr}'`;\n }\n}\n"]}
1
+ {"version":3,"file":"CLIOptionValidator.js","sourceRoot":"","sources":["../../src/cli/CLIOptionValidator.ts"],"names":[],"mappings":";;;;;;AAEA,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,cAAc;IACnB,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C,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,MAAM,GAAG,CAAC;AAChE,CAAC","sourcesContent":["import { CLIOptionParserEntry } from './CLIOptions.js';\n\nconst CLI_OPTION_SRC_NAME = {\n cli: 'Command-line',\n cfg: 'Config 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 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}'`).join(', ')}.`);\n }\n }\n return split as T[];\n }\n\n static validateIncludeContentWithMediaType(entry?: CLIOptionParserEntry) {\n try {\n return this.validateString(entry, 'any', 'none');\n }\n catch (error) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment' ] as const);\n }\n }\n\n static validateIncludePreviewMedia(entry?: CLIOptionParserEntry) {\n try {\n return this.validateBoolean(entry);\n }\n catch (error) {\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) {\n return this.validateStringArray(entry, [ 'image', 'video', 'audio', 'attachment', 'file' ] as const);\n }\n }\n\n static #logEntryKey(entry: CLIOptionParserEntry) {\n const keyStr = entry.src === 'cli' ?\n entry.key :\n `[${entry.section}]->${entry.key}`;\n return `${CLI_OPTION_SRC_NAME[entry.src]} option '${keyStr}'`;\n }\n}\n"]}
@@ -4,10 +4,8 @@ import CommandLineParser from './CommandLineParser.js';
4
4
  import ConfigFileParser from './ConfigFileParser.js';
5
5
  export function getCLIOptions() {
6
6
  const commandLineOptions = CommandLineParser.parse();
7
- let configFileOptions = null;
8
- if (commandLineOptions.configFile?.value) {
9
- configFileOptions = ConfigFileParser.parse(commandLineOptions.configFile.value);
10
- }
7
+ const configFileOptions = commandLineOptions.configFile?.value ? ConfigFileParser.parse(commandLineOptions.configFile.value) : null;
8
+ configFileOptions?.include?.previewMedia;
11
9
  const options = {
12
10
  targetURL: CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURL, configFileOptions?.targetURL), 'No target URL specified'),
13
11
  cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),
@@ -23,10 +21,11 @@ export function getCLIOptions() {
23
21
  },
24
22
  include: {
25
23
  lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),
24
+ postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),
26
25
  campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),
27
26
  contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),
28
- previewMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),
29
- contentMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),
27
+ previewMedia: CLIOptionValidator.validateIncludePreviewMedia(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),
28
+ contentMedia: CLIOptionValidator.validateIncludeContentMedia(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),
30
29
  allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants))
31
30
  },
32
31
  request: {
@@ -1 +1 @@
1
- {"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":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CAAC;IAEF,IAAI,iBAAiB,EAAE,WAAW,EAAE;QAClC,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAqB,EAAE,CAAC,CAAC;YACtF,OAAO,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC;YAC3D,MAAM,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC;YACxD,WAAW,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC;YAClE,gBAAgB,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC;YACnG,QAAQ,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;YAC9F,OAAO,EAAE;gBACP,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;gBACtE,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;gBAChE,UAAU,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;gBAC1E,UAAU,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;aAC3E;YACD,cAAc,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC;YACxE,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC;SACxD,CAAC,CAAC,CAAC;KACL;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { 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 from './CommandLineParser.js';\nimport ConfigFileParser from './ConfigFileParser.js';\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURL: string;\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 key: string;\n value?: string;\n}\n\nexport function getCLIOptions(): CLIOptions {\n const commandLineOptions = CommandLineParser.parse();\n\n let configFileOptions: ReturnType<typeof ConfigFileParser['parse']> | null = null;\n if (commandLineOptions.configFile?.value) {\n configFileOptions = ConfigFileParser.parse(commandLineOptions.configFile.value);\n }\n\n const options: CLIOptions = {\n targetURL: CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURL, configFileOptions?.targetURL), 'No target URL specified'),\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: {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\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.validateBoolean(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants))\n },\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 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 };\n\n if (configFileOptions?.fileLoggers) {\n options.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\n return options;\n}\n"]}
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CAAC,MAAM,CAAC,cAAc,CAAC;YACxE,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC;SACxD,CAAC,CAAC,CAAC;KACL;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { 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 from './CommandLineParser.js';\nimport ConfigFileParser from './ConfigFileParser.js';\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURL: string;\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 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 configFileOptions?.include?.previewMedia;\n\n const options: CLIOptions = {\n targetURL: CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURL, configFileOptions?.targetURL), 'No target URL specified'),\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: {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),\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 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 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 };\n\n if (configFileOptions?.fileLoggers) {\n options.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\n return options;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineParser.d.ts","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAC7G,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AA2ED,MAAM,CAAC,OAAO,OAAO,iBAAiB;;IAEpC,MAAM,CAAC,KAAK,IAAI,sBAAsB;IA6FtC,MAAM,CAAC,SAAS;IAyChB,MAAM,CAAC,gBAAgB;CAmBxB"}
1
+ {"version":3,"file":"CommandLineParser.d.ts","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAC7G,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AA2ED,MAAM,CAAC,OAAO,OAAO,iBAAiB;;IAEpC,MAAM,CAAC,KAAK,IAAI,sBAAsB;IA+FtC,MAAM,CAAC,SAAS;IAyChB,MAAM,CAAC,gBAAgB;CAmBxB"}
@@ -137,6 +137,8 @@ export default class CommandLineParser {
137
137
  media: undefined
138
138
  },
139
139
  include: {
140
+ lockedContent: undefined,
141
+ postsWithMediaType: undefined,
140
142
  campaignInfo: undefined,
141
143
  contentInfo: undefined,
142
144
  previewMedia: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineParser.js","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMzD,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,YAAY;IACvB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;CACb,CAAC;AAEX,MAAM,QAAQ,GAAG;IACf;QACE,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,WAAW,EAAE,0BAA0B;QACvC,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,OAAO;KACd;IACD;QACE,IAAI,EAAE,iBAAiB,CAAC,UAAU;QAClC,WAAW,EAAE,kDAAkD;QAC/D,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;KACpB;IACD;QACE,IAAI,EAAE,iBAAiB,CAAC,SAAS;QACjC,WAAW,EAAE,4BAA4B;QACzC,IAAI,EAAE,MAAM;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cesContent":["import commandLineArgs from 'command-line-args';\nimport commandLineUsage from 'command-line-usage';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { EOL } from 'os';\nimport { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';\nimport { getPackageInfo } from '../utils/PackageInfo.js';\n\nexport interface CommandLineParseResult extends RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry> {\n configFile?: CLIOptionParserEntry;\n}\n\nconst COMMAND_LINE_ARGS = {\n help: 'help',\n configureYouTube: 'configure-youtube',\n configFile: 'config-file',\n targetURL: 'target-url',\n cookie: 'cookie',\n ffmpeg: 'ffmpeg',\n outDir: 'out-dir',\n logLevel: 'log-level',\n noPrompt: 'no-prompt'\n} as const;\n\nconst OPT_DEFS = [\n {\n name: COMMAND_LINE_ARGS.help,\n description: 'Display this usage guide',\n alias: 'h',\n type: Boolean\n },\n {\n name: COMMAND_LINE_ARGS.configFile,\n description: 'Load configuration file for setting full options',\n alias: 'C',\n type: String,\n typeLabel: '<file>'\n },\n {\n name: COMMAND_LINE_ARGS.targetURL,\n description: 'URL of content to download',\n type: String,\n defaultOption: true\n },\n {\n name: COMMAND_LINE_ARGS.cookie,\n description: 'Cookie for accessing patron-only content',\n alias: 'c',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.ffmpeg,\n description: 'Path to FFmpeg executable',\n alias: 'f',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.outDir,\n description: 'Path to directory where content is saved',\n alias: 'o',\n type: String,\n typeLabel: '<dir>'\n },\n {\n name: COMMAND_LINE_ARGS.logLevel,\n description: 'Log level of the console logger: \\'info\\', \\'debug\\', \\'warn\\' or \\'error\\'; set to \\'none\\' to disable the logger.',\n alias: 'l',\n type: String,\n typeLabel: '<level>'\n },\n {\n name: COMMAND_LINE_ARGS.noPrompt,\n description: 'Do not prompt for confirmation to proceed',\n alias: 'y',\n type: Boolean\n },\n {\n name: COMMAND_LINE_ARGS.configureYouTube,\n description: 'Configure YouTube connection',\n type: Boolean\n }\n];\n\nexport default class CommandLineParser {\n\n static parse(): CommandLineParseResult {\n const opts = this.#parseArgs();\n const argv = process.argv;\n\n const __getOptNameUsed = (key: string) => {\n const name = `--${key}`;\n if (argv.includes(name)) {\n return name;\n }\n const alias = OPT_DEFS.find((def) => def.name === key)?.alias;\n if (alias) {\n return `-${alias}`;\n }\n return name;\n };\n\n const __getValue = (key: typeof COMMAND_LINE_ARGS[keyof typeof COMMAND_LINE_ARGS]): CLIOptionParserEntry | undefined => {\n let value = opts[key];\n if (key === COMMAND_LINE_ARGS.noPrompt && value !== undefined) {\n value = '1';\n }\n else if (value === null) {\n throw Error(`Command-line option requires a value for '--${key}'`);\n }\n if (value && typeof value === 'string') {\n return {\n src: 'cli',\n key: __getOptNameUsed(key),\n value: value.trim()\n };\n }\n return undefined;\n };\n\n // Handle --log-level: none\n let consoleLoggerLevel = __getValue(COMMAND_LINE_ARGS.logLevel);\n let consoleLoggerEnabled: CLIOptionParserEntry | undefined;\n if (consoleLoggerLevel?.value === 'none') {\n consoleLoggerEnabled = {\n src: 'cli',\n key: '',\n value: '0'\n };\n consoleLoggerLevel = undefined;\n }\n\n return {\n configFile: __getValue(COMMAND_LINE_ARGS.configFile),\n targetURL: __getValue(COMMAND_LINE_ARGS.targetURL),\n cookie: __getValue(COMMAND_LINE_ARGS.cookie),\n useStatusCache: undefined,\n pathToFFmpeg: __getValue(COMMAND_LINE_ARGS.ffmpeg),\n outDir: __getValue(COMMAND_LINE_ARGS.outDir),\n dirNameFormat: {\n campaign: undefined,\n content: undefined\n },\n filenameFormat: {\n media: undefined\n },\n include: {\n campaignInfo: undefined,\n contentInfo: undefined,\n previewMedia: undefined,\n contentMedia: undefined,\n allMediaVariants: undefined\n },\n request: {\n maxRetries: undefined,\n maxConcurrent: undefined,\n minTime: undefined\n },\n fileExistsAction: {\n content: undefined,\n info: undefined,\n infoAPI: undefined\n },\n noPrompt: __getValue(COMMAND_LINE_ARGS.noPrompt),\n consoleLogger: {\n enabled: consoleLoggerEnabled,\n logLevel: consoleLoggerLevel,\n include: {\n dateTime: undefined,\n level: undefined,\n originator: undefined,\n errorStack: undefined\n },\n dateTimeFormat: undefined,\n color: undefined\n }\n };\n }\n\n static showUsage() {\n let opts;\n try {\n opts = this.#parseArgs();\n }\n catch (error) {\n return false;\n }\n if (opts.help) {\n const content = [\n 'Command-line options override corresponding options in configuration file loaded through \\'-C\\'.',\n EOL,\n 'Project home: {underline https://github.com/patrickkfkan/patreon-dl}'\n ];\n const sections: commandLineUsage.Section[] = [\n {\n header: 'Usage',\n content: 'patreon-dl [OPTION]... URL'\n },\n {\n header: 'Options',\n optionList: OPT_DEFS,\n hide: 'target-url'\n },\n {\n content: content.join(EOL)\n }\n ];\n const banner = getPackageInfo().banner;\n if (banner) {\n sections.unshift({ header: banner, raw: true });\n }\n const usage = commandLineUsage(sections);\n console.log(usage);\n\n return true;\n }\n\n return false;\n }\n\n static configureYouTube() {\n let opts;\n try {\n opts = this.#parseArgs();\n }\n catch (error) {\n return false;\n }\n return opts['configure-youtube'];\n }\n\n static #parseArgs() {\n const opts = commandLineArgs(OPT_DEFS, { stopAtFirstUnknown: true });\n if (opts['_unknown']) {\n const unknownOpt = Object.keys(opts['_unknown'])[0];\n throw Error(`Unknown command-line option '${unknownOpt}'`);\n }\n return opts;\n }\n}\n"]}
1
+ {"version":3,"file":"CommandLineParser.js","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMzD,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAA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OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,gBAAgB;QACrB,IAAI,IAAI,CAAC;QACT,IAAI;YACF,IAAI,GAAG,uBAAA,IAAI,wCAAW,MAAf,IAAI,CAAa,CAAC;SAC1B;QACD,OAAO,KAAK,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC;CAUF;;IAPG,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;QACpB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC,gCAAgC,UAAU,GAAG,CAAC,CAAC;KAC5D;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import commandLineArgs from 'command-line-args';\nimport commandLineUsage from 'command-line-usage';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { EOL } from 'os';\nimport { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';\nimport { getPackageInfo } from '../utils/PackageInfo.js';\n\nexport interface CommandLineParseResult extends RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry> {\n configFile?: CLIOptionParserEntry;\n}\n\nconst COMMAND_LINE_ARGS = {\n help: 'help',\n configureYouTube: 'configure-youtube',\n configFile: 'config-file',\n targetURL: 'target-url',\n cookie: 'cookie',\n ffmpeg: 'ffmpeg',\n outDir: 'out-dir',\n logLevel: 'log-level',\n noPrompt: 'no-prompt'\n} as const;\n\nconst OPT_DEFS = [\n {\n name: COMMAND_LINE_ARGS.help,\n description: 'Display this usage guide',\n alias: 'h',\n type: Boolean\n },\n {\n name: COMMAND_LINE_ARGS.configFile,\n description: 'Load configuration file for setting full options',\n alias: 'C',\n type: String,\n typeLabel: '<file>'\n },\n {\n name: COMMAND_LINE_ARGS.targetURL,\n description: 'URL of content to download',\n type: String,\n defaultOption: true\n },\n {\n name: COMMAND_LINE_ARGS.cookie,\n description: 'Cookie for accessing patron-only content',\n alias: 'c',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.ffmpeg,\n description: 'Path to FFmpeg executable',\n alias: 'f',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.outDir,\n description: 'Path to directory where content is saved',\n alias: 'o',\n type: String,\n typeLabel: '<dir>'\n },\n {\n name: COMMAND_LINE_ARGS.logLevel,\n description: 'Log level of the console logger: \\'info\\', \\'debug\\', \\'warn\\' or \\'error\\'; set to \\'none\\' to disable the logger.',\n alias: 'l',\n type: String,\n typeLabel: '<level>'\n },\n {\n name: COMMAND_LINE_ARGS.noPrompt,\n description: 'Do not prompt for confirmation to proceed',\n alias: 'y',\n type: Boolean\n },\n {\n name: COMMAND_LINE_ARGS.configureYouTube,\n description: 'Configure YouTube connection',\n type: Boolean\n }\n];\n\nexport default class CommandLineParser {\n\n static parse(): CommandLineParseResult {\n const opts = this.#parseArgs();\n const argv = process.argv;\n\n const __getOptNameUsed = (key: string) => {\n const name = `--${key}`;\n if (argv.includes(name)) {\n return name;\n }\n const alias = OPT_DEFS.find((def) => def.name === key)?.alias;\n if (alias) {\n return `-${alias}`;\n }\n return name;\n };\n\n const __getValue = (key: typeof COMMAND_LINE_ARGS[keyof typeof COMMAND_LINE_ARGS]): CLIOptionParserEntry | undefined => {\n let value = opts[key];\n if (key === COMMAND_LINE_ARGS.noPrompt && value !== undefined) {\n value = '1';\n }\n else if (value === null) {\n throw Error(`Command-line option requires a value for '--${key}'`);\n }\n if (value && typeof value === 'string') {\n return {\n src: 'cli',\n key: __getOptNameUsed(key),\n value: value.trim()\n };\n }\n return undefined;\n };\n\n // Handle --log-level: none\n let consoleLoggerLevel = __getValue(COMMAND_LINE_ARGS.logLevel);\n let consoleLoggerEnabled: CLIOptionParserEntry | undefined;\n if (consoleLoggerLevel?.value === 'none') {\n consoleLoggerEnabled = {\n src: 'cli',\n key: '',\n value: '0'\n };\n consoleLoggerLevel = undefined;\n }\n\n return {\n configFile: __getValue(COMMAND_LINE_ARGS.configFile),\n targetURL: __getValue(COMMAND_LINE_ARGS.targetURL),\n cookie: __getValue(COMMAND_LINE_ARGS.cookie),\n useStatusCache: undefined,\n pathToFFmpeg: __getValue(COMMAND_LINE_ARGS.ffmpeg),\n outDir: __getValue(COMMAND_LINE_ARGS.outDir),\n dirNameFormat: {\n campaign: undefined,\n content: undefined\n },\n filenameFormat: {\n media: undefined\n },\n include: {\n lockedContent: undefined,\n postsWithMediaType: undefined,\n campaignInfo: undefined,\n contentInfo: undefined,\n previewMedia: undefined,\n contentMedia: undefined,\n allMediaVariants: undefined\n },\n request: {\n maxRetries: undefined,\n maxConcurrent: undefined,\n minTime: undefined\n },\n fileExistsAction: {\n content: undefined,\n info: undefined,\n infoAPI: undefined\n },\n noPrompt: __getValue(COMMAND_LINE_ARGS.noPrompt),\n consoleLogger: {\n enabled: consoleLoggerEnabled,\n logLevel: consoleLoggerLevel,\n include: {\n dateTime: undefined,\n level: undefined,\n originator: undefined,\n errorStack: undefined\n },\n dateTimeFormat: undefined,\n color: undefined\n }\n };\n }\n\n static showUsage() {\n let opts;\n try {\n opts = this.#parseArgs();\n }\n catch (error) {\n return false;\n }\n if (opts.help) {\n const content = [\n 'Command-line options override corresponding options in configuration file loaded through \\'-C\\'.',\n EOL,\n 'Project home: {underline https://github.com/patrickkfkan/patreon-dl}'\n ];\n const sections: commandLineUsage.Section[] = [\n {\n header: 'Usage',\n content: 'patreon-dl [OPTION]... URL'\n },\n {\n header: 'Options',\n optionList: OPT_DEFS,\n hide: 'target-url'\n },\n {\n content: content.join(EOL)\n }\n ];\n const banner = getPackageInfo().banner;\n if (banner) {\n sections.unshift({ header: banner, raw: true });\n }\n const usage = commandLineUsage(sections);\n console.log(usage);\n\n return true;\n }\n\n return false;\n }\n\n static configureYouTube() {\n let opts;\n try {\n opts = this.#parseArgs();\n }\n catch (error) {\n return false;\n }\n return opts['configure-youtube'];\n }\n\n static #parseArgs() {\n const opts = commandLineArgs(OPT_DEFS, { stopAtFirstUnknown: true });\n if (opts['_unknown']) {\n const unknownOpt = Object.keys(opts['_unknown'])[0];\n throw Error(`Unknown command-line option '${unknownOpt}'`);\n }\n return opts;\n }\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;AA+DjE,KAAK,qBAAqB,GAAG,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAE7F,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAEnC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB;CAsGlD"}
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;AAgEjE,KAAK,qBAAqB,GAAG,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAE7F,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAEnC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB;CAuGlD"}
@@ -26,6 +26,7 @@ const CONFIG_FILE_PROPS = {
26
26
  },
27
27
  include: {
28
28
  lockedContent: 'include:locked.content',
29
+ postsWithMediaType: 'include:posts.with.media.type',
29
30
  campaignInfo: 'include:campaign.info',
30
31
  contentInfo: 'include:content.info',
31
32
  previewMedia: 'include:preview.media',
@@ -87,6 +88,7 @@ export default class ConfigFileParser {
87
88
  },
88
89
  include: {
89
90
  lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),
91
+ postsWithMediaType: __getValue(CONFIG_FILE_PROPS.include.postsWithMediaType),
90
92
  campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),
91
93
  contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),
92
94
  previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),
@@ -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,wBAAwB;QACvC,YAAY,EAAE,uBAAuB;QACrC,WAAW,EAAE,sBAAsB;QACnC,YAAY,EAAE,uBAAuB;QACrC,YAAY,EAAE,uBAAuB;QACrC,gBAAgB,EAAE,4BAA4B;KAC/C;IACD,OAAO,EAAE;QACP,UAAU,EAAE,qBAAqB;QACjC,aAAa,EAAE,wBAAwB;QACvC,O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E,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 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\ntype ConfigFileParseResult = RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry>;\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 targetURL: __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 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.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,wBAAwB;QACvC,kBAAkB,EAAE,+BAA+B;QACnD,YAAY,EAAE,uBAAuB;QAC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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 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\ntype ConfigFileParseResult = RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry>;\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 targetURL: __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 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,4 +1,6 @@
1
- export type DownloaderType = 'product' | 'post';
1
+ import { Post } from '../entities/Post.js';
2
+ import { Product } from '../entities/Product.js';
3
+ export type DownloaderType = Product | Post;
2
4
  export interface BootstrapData {
3
5
  type: string;
4
6
  targetURL: string;
@@ -22,7 +24,7 @@ export interface PostDownloaderBootstrapData extends BootstrapData {
22
24
  filters?: Record<string, any>;
23
25
  };
24
26
  }
25
- export type DownloaderBootstrapData<T extends DownloaderType> = T extends 'product' ? ProductDownloaderBootstrapData : T extends 'post' ? PostDownloaderBootstrapData : never;
27
+ export type DownloaderBootstrapData<T extends DownloaderType> = T['type'] extends 'product' ? ProductDownloaderBootstrapData : T['type'] extends 'post' ? PostDownloaderBootstrapData : never;
26
28
  export default class Bootstrap {
27
29
  static getDownloaderBootstrapDataByURL(url: string): ProductDownloaderBootstrapData | PostDownloaderBootstrapData | null;
28
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Bootstrap.d.ts","sourceRoot":"","sources":["../../src/downloaders/Bootstrap.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,8BAA+B,SAAQ,aAAa;IACnE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,2BAA4B,SAAQ,aAAa;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG;QACF,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,GAAG;QACF,IAAI,EAAE,cAAc,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,CAAC;CACH;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAC1D,CAAC,SAAS,SAAS,GAAG,8BAA8B,GACpD,CAAC,SAAS,MAAM,GAAG,2BAA2B,GAC9C,KAAK,CAAC;AAER,MAAM,CAAC,OAAO,OAAO,SAAS;IAE5B,MAAM,CAAC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C;SAClC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import URLHelper from '../utils/URLHelper.js';\n\nexport type DownloaderType = 'product' | 'post';\n\nexport interface BootstrapData {\n type: string;\n targetURL: string;\n}\n\nexport interface ProductDownloaderBootstrapData extends BootstrapData {\n type: 'product';\n productId: string;\n}\n\nexport interface PostDownloaderBootstrapData extends BootstrapData {\n type: 'post';\n postFetch: {\n type: 'single';\n postId: string;\n } | {\n type: 'byUser';\n vanity: string;\n filters?: Record<string, any>;\n } | {\n type: 'byCollection';\n collectionId: string;\n filters?: Record<string, any>;\n };\n}\n\nexport type DownloaderBootstrapData<T extends DownloaderType> =\n T extends 'product' ? ProductDownloaderBootstrapData :\n T extends 'post' ? PostDownloaderBootstrapData :\n never;\n\nexport default class Bootstrap {\n\n static getDownloaderBootstrapDataByURL(url: string) {\n const analysis = URLHelper.analyzeURL(url);\n if (!analysis) {\n return null;\n }\n\n if (analysis.type === 'product') {\n return {\n type: 'product',\n targetURL: url,\n productId: analysis.productId\n } as ProductDownloaderBootstrapData;\n }\n\n if (analysis.type === 'postsByUser') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'byUser',\n vanity: analysis.vanity,\n filters: analysis.filters\n }\n } as PostDownloaderBootstrapData;\n }\n\n if (analysis.type === 'postsByCollection') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'byCollection',\n collectionId: analysis.collectionId,\n filters: analysis.filters\n }\n } as PostDownloaderBootstrapData;\n }\n\n if (analysis.type === 'post') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'single',\n postId: analysis.postId,\n slug: analysis.slug\n }\n } as PostDownloaderBootstrapData;\n }\n\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"Bootstrap.js","sourceRoot":"","sources":["../../src/downloaders/Bootstrap.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAmC9C,MAAM,CAAC,OAAO,OAAO,SAAS;IAE5B,MAAM,CAAC,+BAA+B,CAAC,GAAW;QAChD,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,IAAI,CAAC;SACb;QAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;YAC/B,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,QAAQ,CAAC,SAAS;aACI,CAAC;SACrC;QAED,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa,EAAE;YACnC,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;iBAC1B;aAC6B,CAAC;SAClC;QAED,IAAI,QAAQ,CAAC,IAAI,KAAK,mBAAmB,EAAE;YACzC,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE;oBACT,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,QAAQ,CAAC,YAAY;oBACnC,OAAO,EAAE,QAAQ,CAAC,OAAO;iBAC1B;aAC6B,CAAC;SAClC;QAED,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE;YAC5B,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACpB;aAC6B,CAAC;SAClC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { Post } from '../entities/Post.js';\nimport { Product } from '../entities/Product.js';\nimport URLHelper from '../utils/URLHelper.js';\n\nexport type DownloaderType = Product | Post;\n\nexport interface BootstrapData {\n type: string;\n targetURL: string;\n}\n\nexport interface ProductDownloaderBootstrapData extends BootstrapData {\n type: 'product';\n productId: string;\n}\n\nexport interface PostDownloaderBootstrapData extends BootstrapData {\n type: 'post';\n postFetch: {\n type: 'single';\n postId: string;\n } | {\n type: 'byUser';\n vanity: string;\n filters?: Record<string, any>;\n } | {\n type: 'byCollection';\n collectionId: string;\n filters?: Record<string, any>;\n };\n}\n\nexport type DownloaderBootstrapData<T extends DownloaderType> =\n T['type'] extends 'product' ? ProductDownloaderBootstrapData :\n T['type'] extends 'post' ? PostDownloaderBootstrapData :\n never;\n\nexport default class Bootstrap {\n\n static getDownloaderBootstrapDataByURL(url: string) {\n const analysis = URLHelper.analyzeURL(url);\n if (!analysis) {\n return null;\n }\n\n if (analysis.type === 'product') {\n return {\n type: 'product',\n targetURL: url,\n productId: analysis.productId\n } as ProductDownloaderBootstrapData;\n }\n\n if (analysis.type === 'postsByUser') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'byUser',\n vanity: analysis.vanity,\n filters: analysis.filters\n }\n } as PostDownloaderBootstrapData;\n }\n\n if (analysis.type === 'postsByCollection') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'byCollection',\n collectionId: analysis.collectionId,\n filters: analysis.filters\n }\n } as PostDownloaderBootstrapData;\n }\n\n if (analysis.type === 'post') {\n return {\n type: 'post',\n targetURL: url,\n postFetch: {\n type: 'single',\n postId: analysis.postId,\n slug: analysis.slug\n }\n } as PostDownloaderBootstrapData;\n }\n\n return null;\n }\n}\n"]}
@@ -24,7 +24,7 @@ export default abstract class Downloader<T extends DownloaderType> extends Event
24
24
  #private;
25
25
  abstract name: string;
26
26
  protected fetcher: Fetcher;
27
- protected config: deepFreeze.DeepReadonly<DownloaderConfig<T>>;
27
+ protected config: DownloaderConfig<T>;
28
28
  protected logger?: Logger | null;
29
29
  constructor(bootstrap: DownloaderBootstrapData<T>, options?: DownloaderOptions);
30
30
  protected createDownloadTaskBatch(name: string, ...createTasks: Array<CreateDownloadTaskParams | null>): DownloadTaskBatch;
@@ -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;AAK5D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQ3D,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,CAAC;CACpC;AAED,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,UAAU,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,YAAY;;IAErF,QAAQ,C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IAAI,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,OAAO;CAItF"}
@@ -19,7 +19,6 @@ import { getDownloaderInit } from './DownloaderOptions.js';
19
19
  import { commonLog } from '../utils/logging/Logger.js';
20
20
  import FSHelper from '../utils/FSHelper.js';
21
21
  import DownloadTaskBatch from './task/DownloadTaskBatch.js';
22
- import FFmpegDownloadTask from './task/FFmpegDownloadTask.js';
23
22
  import DownloadTaskFactory from './task/DownloadTaskFactory.js';
24
23
  import FilenameFormatHelper from '../utils/FilenameFormatHelper.js';
25
24
  import { generateCampaignSummary } from './templates/CampaignInfo.js';
@@ -28,16 +27,17 @@ import URLHelper from '../utils/URLHelper.js';
28
27
  import { AbortError } from 'node-fetch';
29
28
  import ffmpeg from 'fluent-ffmpeg';
30
29
  import InnertubeLoader from '../utils/InnertubeLoader.js';
30
+ import FFmpegDownloadTaskBase from './task/FFmpegDownloadTaskBase.js';
31
31
  export default class Downloader extends EventEmitter {
32
32
  constructor(bootstrap, options) {
33
33
  super();
34
34
  _Downloader_instances.add(this);
35
35
  _Downloader_hasEmittedEndEventOnAbort.set(this, void 0);
36
36
  __classPrivateFieldGet(this, _Downloader_instances, "m", _Downloader_validateOptions).call(this, options);
37
- this.config = deepFreeze({
37
+ this.config = {
38
38
  ...bootstrap,
39
39
  ...getDownloaderInit(options)
40
- });
40
+ };
41
41
  this.fetcher = new Fetcher(options?.cookie, options?.logger);
42
42
  this.logger = options?.logger;
43
43
  if (this.config.pathToFFmpeg) {
@@ -65,7 +65,7 @@ export default class Downloader extends EventEmitter {
65
65
  batch.on('taskStart', ({ task }) => {
66
66
  const retryOrBeginStr = task.retryCount > 0 ? 'retry' : 'begin';
67
67
  this.log('info', `Download ${retryOrBeginStr} (${__getDownloadIdString(task, batch)}): [type: ${task.srcEntity.type}; ID: #${task.srcEntity.id}] -> ${task.resolvedDestFilename}`);
68
- if (task instanceof FFmpegDownloadTask) {
68
+ if (task instanceof FFmpegDownloadTaskBase) {
69
69
  const retryOrBeginStr = task.retryCount > 0 ? 'Retry' : 'Begin';
70
70
  this.log('info', `${retryOrBeginStr} downloading through FFmpeg (${__getDownloadIdString(task, batch)}): ${task.commandLine}`);
71
71
  }
@@ -163,6 +163,7 @@ export default class Downloader extends EventEmitter {
163
163
  saveCampaignInfo(campaign, signal) {
164
164
  return new Promise(async (resolve) => {
165
165
  if (!this.config.include.campaignInfo) {
166
+ resolve();
166
167
  return;
167
168
  }
168
169
  if (this.checkAbortSignal(signal, resolve)) {
@@ -179,6 +180,7 @@ export default class Downloader extends EventEmitter {
179
180
  }
180
181
  if (!campaign) {
181
182
  this.log('warn', 'Skipped saving campaign info: target unavailable');
183
+ resolve();
182
184
  return;
183
185
  }
184
186
  this.log('info', `Save campaign info #${campaign.id}`);
@@ -251,7 +253,7 @@ export default class Downloader extends EventEmitter {
251
253
  commonLog(this.logger, level, this.name, ...msg);
252
254
  }
253
255
  getConfig() {
254
- return this.config;
256
+ return deepFreeze(this.config);
255
257
  }
256
258
  checkAbortSignal(signal, resolve) {
257
259
  if (signal && signal.aborted) {