patreon-dl 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -209
- package/dist/browse/db/CampaignDBMixin.d.ts +3 -3
- package/dist/browse/db/ContentDBMixin.d.ts +13 -13
- package/dist/browse/db/ContentDBMixin.js +1 -1
- package/dist/browse/db/ContentDBMixin.js.map +1 -1
- package/dist/browse/db/MediaDBMixin.js +1 -1
- package/dist/browse/db/MediaDBMixin.js.map +1 -1
- package/dist/browse/db/index.d.ts +16 -16
- package/dist/browse/server/handler/CampaignAPIRequesthandler.js +5 -0
- package/dist/browse/server/handler/CampaignAPIRequesthandler.js.map +1 -1
- package/dist/browse/web/assets/index-CtjPL2rI.js +218 -0
- package/dist/browse/web/index.html +1 -1
- package/dist/cli/CLIOptions.js +6 -2
- package/dist/cli/CLIOptions.js.map +1 -1
- package/dist/cli/ConfigFileParser.js +1 -1
- package/dist/cli/ConfigFileParser.js.map +1 -1
- package/dist/downloaders/Downloader.js +1 -1
- package/dist/downloaders/Downloader.js.map +1 -1
- package/dist/downloaders/PostDownloader.js +5 -5
- package/dist/downloaders/PostDownloader.js.map +1 -1
- package/dist/downloaders/PostsFetcher.js +3 -3
- package/dist/downloaders/PostsFetcher.js.map +1 -1
- package/dist/downloaders/task/DownloadTask.js +11 -1
- package/dist/downloaders/task/DownloadTask.js.map +1 -1
- package/dist/entities/MediaItem.d.ts +1 -0
- package/dist/entities/MediaItem.js.map +1 -1
- package/dist/parsers/PageParser.js +4 -1
- package/dist/parsers/PageParser.js.map +1 -1
- package/dist/parsers/PostParser.d.ts +4 -1
- package/dist/parsers/PostParser.js +82 -5
- package/dist/parsers/PostParser.js.map +1 -1
- package/dist/utils/Fetcher.d.ts +1 -0
- package/dist/utils/Fetcher.js +5 -0
- package/dist/utils/Fetcher.js.map +1 -1
- package/dist/utils/FilenameFormatHelper.d.ts +1 -1
- package/dist/utils/FilenameFormatHelper.js +4 -1
- package/dist/utils/FilenameFormatHelper.js.map +1 -1
- package/dist/utils/Formatter.d.ts +1 -1
- package/dist/utils/Formatter.js +1 -1
- package/dist/utils/Formatter.js.map +1 -1
- package/dist/utils/logging/FileLogger.js +1 -0
- package/dist/utils/logging/FileLogger.js.map +1 -1
- package/package.json +1 -1
- package/dist/browse/web/assets/index-CtZbx-Du.js +0 -218
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link id="theme-stylesheet-0" rel="stylesheet" href="/themes/bootstrap/default/css/bootstrap.min.css">
|
|
7
7
|
<title>patreon-dl</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CtjPL2rI.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CQnQD2xz.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/cli/CLIOptions.js
CHANGED
|
@@ -175,7 +175,7 @@ function readTargetsFile(file) {
|
|
|
175
175
|
contentInfo: 'include.content.info',
|
|
176
176
|
previewMedia: 'include.preview.media',
|
|
177
177
|
contentMedia: 'include.content.media',
|
|
178
|
-
protectedMedia: '
|
|
178
|
+
protectedMedia: 'include.protected.media',
|
|
179
179
|
allMediaVariants: 'include.all.media.variants',
|
|
180
180
|
mediaThumbnails: 'include.media.thumbnails',
|
|
181
181
|
imagesByFilename: 'include.images.by.filename',
|
|
@@ -183,7 +183,11 @@ function readTargetsFile(file) {
|
|
|
183
183
|
attachmentsByFilename: 'include.attachments.by.filename',
|
|
184
184
|
comments: 'include.comments'
|
|
185
185
|
};
|
|
186
|
-
const
|
|
186
|
+
const targetsFile = path.resolve(file);
|
|
187
|
+
if (!fs.statSync(targetsFile).isFile()) {
|
|
188
|
+
throw Error('Targets file is not a file');
|
|
189
|
+
}
|
|
190
|
+
const lines = fs.readFileSync(targetsFile)
|
|
187
191
|
.toString('utf-8')
|
|
188
192
|
// Replace Windows line breaks with Unix ones and then split
|
|
189
193
|
.replace(/\r\n/g, '\n').split('\n')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAA2C,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGxF,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,iBAAkD,MAAM,wBAAwB,CAAC;AACxF,OAAO,gBAAgD,MAAM,uBAAuB,CAAC;AACrF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,YAAY,MAAM,0BAA0B,CAAC;AA8BpD,MAAM,UAAU,aAAa,CAAC,cAAc,GAAG,KAAK;IAClD,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAErD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpI,IAAI,UAAU,GAAwB,EAAE,CAAC;IAEzC,IAAI,kBAAkB,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC;QACzD,IAAI,CAAC,WAAW;YACd,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC3B,CAAC,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAC3E,CAAC;YACD,MAAM,KAAK,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,GAAG,uCAAuC,CAAC,CAAC;QACzF,CAAC;QACD,UAAU,GAAG,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,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GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;gBACnE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI;aACtD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\nimport { type DownloaderIncludeOptions, type DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { type DeepPartial, type RecursivePropsTo, pickDefined } from '../utils/Misc.js';\nimport { type ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { type FileLoggerType, type FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { type CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { type ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\nimport ObjectHelper from '../utils/ObjectHelper.js';\n\nexport interface CLITargetURLEntry {\n url: string;\n // Target-specific 'include' options\n include?: DownloaderIncludeOptions;\n}\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURLs: CLITargetURLEntry[];\n noPrompt: boolean;\n consoleLogger: ConsoleLoggerOptions;\n fileLoggers?: Omit<FileLoggerOptions<FileLoggerType.Downloader>, 'init'>[];\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(skipTargetURLs: true): Omit<CLIOptions, 'targetURLs'>;\nexport function getCLIOptions(skipTargetURLs?: false): CLIOptions;\nexport function getCLIOptions(skipTargetURLs = false): CLIOptions | Omit<CLIOptions, 'targetURLs'> {\n const commandLineOptions = CommandLineParser.parse();\n\n const configFileOptions = commandLineOptions.configFile?.value ? ConfigFileParser.parse(commandLineOptions.configFile.value) : null;\n let targetURLs: CLITargetURLEntry[] = [];\n\n if (commandLineOptions.debugAPI) {\n const apiDataFile = commandLineOptions.targetURLs?.value;\n if (!apiDataFile ||\n !fs.existsSync(apiDataFile) ||\n !['post-api.json', 'product-api.json'].includes(path.basename(apiDataFile))\n ) {\n throw Error(`${commandLineOptions.debugAPI.key}: target is not a local API data file`);\n }\n targetURLs = [{ url: apiDataFile }];\n }\n else if (!skipTargetURLs) {\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\n const { consoleLogger, fileLoggers } = getCLILoggerOptions(commandLineOptions, configFileOptions);\n const proxy = getProxyOptions(configFileOptions);\n\n const options = {\n cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),\n useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),\n stopOn: CLIOptionValidator.validateString(pickDefined(commandLineOptions.stopOn, configFileOptions?.stopOn), 'never', 'postPreviouslyDownloaded', 'postPublishDateOutOfRange', 'previouslyDownloaded', 'publishDateOutOfRange'),\n pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),\n pathToDeno: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToDeno, configFileOptions?.pathToDeno)),\n outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),\n dirNameFormat: {\n campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))\n },\n filenameFormat: {\n media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))\n },\n include: getCLIIncludeOptions(commandLineOptions, configFileOptions),\n request: {\n maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),\n maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),\n minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime)),\n proxy,\n userAgent: CLIOptionValidator.validateString(pickDefined(commandLineOptions?.request?.userAgent, configFileOptions?.request?.userAgent))\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 maxVideoResolution: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions.maxVideoResolution, configFileOptions?.maxVideoResolution)),\n noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,\n dryRun: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.dryRun, configFileOptions?.dryRun)) || false,\n consoleLogger,\n fileLoggers\n } satisfies Omit<CLIOptions, 'targetURLs'>;\n\n if (skipTargetURLs) {\n return options;\n }\n\n return {\n targetURLs,\n ...options\n } satisfies CLIOptions;\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): Omit<FileLoggerOptions<FileLoggerType.Downloader>, 'init'> => ({\n enabled: CLIOptionValidator.validateBoolean(logger.enabled),\n logDir: CLIOptionValidator.validateString(logger.logDir),\n logFilename: CLIOptionValidator.validateString(logger.logFilename),\n fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),\n logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),\n level: CLIOptionValidator.validateBoolean(logger.include?.level),\n originator: CLIOptionValidator.validateBoolean(logger.include?.originator),\n errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)\n },\n dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),\n color: CLIOptionValidator.validateBoolean(logger.color)\n }));\n }\n return {\n consoleLogger,\n fileLoggers\n };\n}\n\nfunction getCLIIncludeOptions(commandLineOptions: CommandLineParseResult, configFileOptions?: ConfigFileParseResult | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n return {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),\n postsInTier: CLIOptionValidator.validateIncludeContentInTier(pickDefined(commandLineOptions.include?.postsInTier, configFileOptions?.include?.postsInTier)),\n postsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.after, configFileOptions?.include?.postsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.before, configFileOptions?.include?.postsPublished?.before)) || null,\n },\n productsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.productsPublished?.after, configFileOptions?.include?.productsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.productsPublished?.before, configFileOptions?.include?.productsPublished?.before)) || null,\n },\n campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),\n contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),\n previewMedia: CLIOptionValidator.validateIncludePreviewMedia(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateIncludeContentMedia(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n protectedMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.protectedMedia, configFileOptions?.include?.protectedMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants)),\n mediaThumbnails: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.mediaThumbnails, configFileOptions?.include?.mediaThumbnails)),\n mediaByFilename: {\n images: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.images, configFileOptions?.include?.mediaByFilename?.images)) || null,\n audio: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.audio, configFileOptions?.include?.mediaByFilename?.audio)) || null,\n attachments: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.attachments, configFileOptions?.include?.mediaByFilename?.attachments)) || null\n },\n comments: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.comments, configFileOptions?.include?.comments))\n };\n}\n\nfunction getEmbedDownloaderOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.embedDownloaders) {\n return configFileOptions?.embedDownloaders.map((dl) => ({\n provider: CLIOptionValidator.validateRequired(dl.provider),\n exec: CLIOptionValidator.validateRequired(dl.exec)\n }));\n }\n return undefined;\n}\n\nfunction getProxyOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.request?.proxy && configFileOptions.request.proxy.url?.value?.trim()) {\n return {\n url: CLIOptionValidator.validateProxyURL(configFileOptions.request.proxy.url),\n rejectUnauthorizedTLS: CLIOptionValidator.validateBoolean(configFileOptions.request.proxy.rejectUnauthorizedTLS)\n };\n }\n return null;\n}\n\nfunction readTargetsFile(file: string) {\n const includeKeys = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\n postsPublishedAfter: 'include.posts.published.after',\n postsPublishedBefore: 'include.posts.published.before',\n productsPublishedAfter: 'include.products.published.after',\n productsPublishedBefore: 'include.products.published.before',\n campaignInfo: 'include.campaign.info',\n contentInfo: 'include.content.info',\n previewMedia: 'include.preview.media',\n contentMedia: 'include.content.media',\n protectedMedia: 'nclude.protected.media',\n allMediaVariants: 'include.all.media.variants',\n mediaThumbnails: 'include.media.thumbnails',\n imagesByFilename: 'include.images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include.attachments.by.filename',\n comments: 'include.comments'\n };\n\n const lines = fs.readFileSync(file)\n .toString('utf-8')\n // Replace Windows line breaks with Unix ones and then split\n .replace(/\\r\\n/g, '\\n').split('\\n')\n .map((line) => line.trim());\n\n const currentTargets: { url: string; include?: RecursivePropsTo<DeepPartial<DownloaderIncludeOptions>, CLIOptionParserEntry>; }[] = [];\n for (let ln = 0; ln < lines.length; ln++) {\n const line = lines[ln];\n if (line === '' || line.startsWith('#')) {\n continue;\n }\n try {\n const match = Object.entries(includeKeys).find((e) => line.startsWith(e[1]));\n if (match) {\n const [ optName, matchKey ] = match;\n const eq = line.indexOf('=');\n const propValue = (eq >= matchKey.length ? line.substring(eq + 1) : '').trim();\n if (propValue) {\n const target = currentTargets.at(-1);\n if (target) {\n const entry: CLIOptionParserEntry = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n if (!target.include) {\n target.include = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter || matchKey === includeKeys.postsPublishedBefore) {\n if (!target.include.postsPublished) {\n target.include.postsPublished = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter) {\n target.include.postsPublished.after = entry;\n }\n else {\n target.include.postsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.productsPublishedAfter || matchKey === includeKeys.productsPublishedBefore) {\n if (!target.include.productsPublished) {\n target.include.productsPublished = {};\n }\n if (matchKey === includeKeys.productsPublishedAfter) {\n target.include.productsPublished.after = entry;\n }\n else {\n target.include.productsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.imagesByFilename || matchKey === includeKeys.audioByFilename ||\n matchKey === includeKeys.attachmentsByFilename) {\n if (!target.include.mediaByFilename) {\n target.include.mediaByFilename = {};\n }\n switch (matchKey) {\n case includeKeys.imagesByFilename:\n target.include.mediaByFilename.images = entry;\n break;\n case includeKeys.audioByFilename:\n target.include.mediaByFilename.audio = entry;\n break;\n case includeKeys.attachmentsByFilename:\n target.include.mediaByFilename.attachments = entry;\n break;\n }\n }\n else {\n target.include[optName as keyof DownloaderIncludeOptions] = entry;\n }\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error: any) {\n const errMsg = error instanceof Error ? error.message : error;\n throw Error(`Error parsing targets file (line ${ln})${errMsg ? `: ${errMsg}` : ''}`);\n }\n }\n\n const result: CLITargetURLEntry[] = [];\n for (const target of currentTargets) {\n const v: CLITargetURLEntry = { url: target.url };\n if (target.include) {\n const includeOpts = ObjectHelper.clean(getCLIIncludeOptions(target), {\n deep: true, cleanNulls: true, cleanEmptyObjects: true\n });\n if (Object.entries(includeOpts).length > 0) {\n v.include = includeOpts;\n }\n }\n result.push(v);\n }\n\n return result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AAAA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C,MAAM,CAAC,GAAsB,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;gBACnE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI;aACtD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import fs from 'fs';\nimport { type DownloaderIncludeOptions, type DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { type DeepPartial, type RecursivePropsTo, pickDefined } from '../utils/Misc.js';\nimport { type ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { type FileLoggerType, type FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser, { type CommandLineParseResult } from './CommandLineParser.js';\nimport ConfigFileParser, { type ConfigFileParseResult } from './ConfigFileParser.js';\nimport path from 'path';\nimport ObjectHelper from '../utils/ObjectHelper.js';\n\nexport interface CLITargetURLEntry {\n url: string;\n // Target-specific 'include' options\n include?: DownloaderIncludeOptions;\n}\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURLs: CLITargetURLEntry[];\n noPrompt: boolean;\n consoleLogger: ConsoleLoggerOptions;\n fileLoggers?: Omit<FileLoggerOptions<FileLoggerType.Downloader>, 'init'>[];\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(skipTargetURLs: true): Omit<CLIOptions, 'targetURLs'>;\nexport function getCLIOptions(skipTargetURLs?: false): CLIOptions;\nexport function getCLIOptions(skipTargetURLs = false): CLIOptions | Omit<CLIOptions, 'targetURLs'> {\n const commandLineOptions = CommandLineParser.parse();\n\n const configFileOptions = commandLineOptions.configFile?.value ? ConfigFileParser.parse(commandLineOptions.configFile.value) : null;\n let targetURLs: CLITargetURLEntry[] = [];\n\n if (commandLineOptions.debugAPI) {\n const apiDataFile = commandLineOptions.targetURLs?.value;\n if (!apiDataFile ||\n !fs.existsSync(apiDataFile) ||\n !['post-api.json', 'product-api.json'].includes(path.basename(apiDataFile))\n ) {\n throw Error(`${commandLineOptions.debugAPI.key}: target is not a local API data file`);\n }\n targetURLs = [{ url: apiDataFile }];\n }\n else if (!skipTargetURLs) {\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\n const { consoleLogger, fileLoggers } = getCLILoggerOptions(commandLineOptions, configFileOptions);\n const proxy = getProxyOptions(configFileOptions);\n\n const options = {\n cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),\n useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),\n stopOn: CLIOptionValidator.validateString(pickDefined(commandLineOptions.stopOn, configFileOptions?.stopOn), 'never', 'postPreviouslyDownloaded', 'postPublishDateOutOfRange', 'previouslyDownloaded', 'publishDateOutOfRange'),\n pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),\n pathToDeno: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToDeno, configFileOptions?.pathToDeno)),\n outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),\n dirNameFormat: {\n campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))\n },\n filenameFormat: {\n media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))\n },\n include: getCLIIncludeOptions(commandLineOptions, configFileOptions),\n request: {\n maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),\n maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),\n minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime)),\n proxy,\n userAgent: CLIOptionValidator.validateString(pickDefined(commandLineOptions?.request?.userAgent, configFileOptions?.request?.userAgent))\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 maxVideoResolution: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions.maxVideoResolution, configFileOptions?.maxVideoResolution)),\n noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,\n dryRun: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.dryRun, configFileOptions?.dryRun)) || false,\n consoleLogger,\n fileLoggers\n } satisfies Omit<CLIOptions, 'targetURLs'>;\n\n if (skipTargetURLs) {\n return options;\n }\n\n return {\n targetURLs,\n ...options\n } satisfies CLIOptions;\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): Omit<FileLoggerOptions<FileLoggerType.Downloader>, 'init'> => ({\n enabled: CLIOptionValidator.validateBoolean(logger.enabled),\n logDir: CLIOptionValidator.validateString(logger.logDir),\n logFilename: CLIOptionValidator.validateString(logger.logFilename),\n fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),\n logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),\n level: CLIOptionValidator.validateBoolean(logger.include?.level),\n originator: CLIOptionValidator.validateBoolean(logger.include?.originator),\n errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)\n },\n dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),\n color: CLIOptionValidator.validateBoolean(logger.color)\n }));\n }\n return {\n consoleLogger,\n fileLoggers\n };\n}\n\nfunction getCLIIncludeOptions(commandLineOptions: CommandLineParseResult, configFileOptions?: ConfigFileParseResult | null) {\n if (!commandLineOptions) {\n commandLineOptions = CommandLineParser.parse();\n }\n return {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n postsWithMediaType: CLIOptionValidator.validateIncludeContentWithMediaType(pickDefined(commandLineOptions.include?.postsWithMediaType, configFileOptions?.include?.postsWithMediaType)),\n postsInTier: CLIOptionValidator.validateIncludeContentInTier(pickDefined(commandLineOptions.include?.postsInTier, configFileOptions?.include?.postsInTier)),\n postsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.after, configFileOptions?.include?.postsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.postsPublished?.before, configFileOptions?.include?.postsPublished?.before)) || null,\n },\n productsPublished: {\n after: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.productsPublished?.after, configFileOptions?.include?.productsPublished?.after)) || null,\n before: CLIOptionValidator.validateDateTime(pickDefined(commandLineOptions.include?.productsPublished?.before, configFileOptions?.include?.productsPublished?.before)) || null,\n },\n campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),\n contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),\n previewMedia: CLIOptionValidator.validateIncludePreviewMedia(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateIncludeContentMedia(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n protectedMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.protectedMedia, configFileOptions?.include?.protectedMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants)),\n mediaThumbnails: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.mediaThumbnails, configFileOptions?.include?.mediaThumbnails)),\n mediaByFilename: {\n images: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.images, configFileOptions?.include?.mediaByFilename?.images)) || null,\n audio: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.audio, configFileOptions?.include?.mediaByFilename?.audio)) || null,\n attachments: CLIOptionValidator.validateString(pickDefined(commandLineOptions.include?.mediaByFilename?.attachments, configFileOptions?.include?.mediaByFilename?.attachments)) || null\n },\n comments: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.comments, configFileOptions?.include?.comments))\n };\n}\n\nfunction getEmbedDownloaderOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.embedDownloaders) {\n return configFileOptions?.embedDownloaders.map((dl) => ({\n provider: CLIOptionValidator.validateRequired(dl.provider),\n exec: CLIOptionValidator.validateRequired(dl.exec)\n }));\n }\n return undefined;\n}\n\nfunction getProxyOptions(configFileOptions?: ConfigFileParseResult | null) {\n if (configFileOptions?.request?.proxy && configFileOptions.request.proxy.url?.value?.trim()) {\n return {\n url: CLIOptionValidator.validateProxyURL(configFileOptions.request.proxy.url),\n rejectUnauthorizedTLS: CLIOptionValidator.validateBoolean(configFileOptions.request.proxy.rejectUnauthorizedTLS)\n };\n }\n return null;\n}\n\nfunction readTargetsFile(file: string) {\n const includeKeys = {\n lockedContent: 'include.locked.content',\n postsWithMediaType: 'include.posts.with.media.type',\n postsInTier: 'include.posts.in.tier',\n postsPublishedAfter: 'include.posts.published.after',\n postsPublishedBefore: 'include.posts.published.before',\n productsPublishedAfter: 'include.products.published.after',\n productsPublishedBefore: 'include.products.published.before',\n campaignInfo: 'include.campaign.info',\n contentInfo: 'include.content.info',\n previewMedia: 'include.preview.media',\n contentMedia: 'include.content.media',\n protectedMedia: 'include.protected.media',\n allMediaVariants: 'include.all.media.variants',\n mediaThumbnails: 'include.media.thumbnails',\n imagesByFilename: 'include.images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include.attachments.by.filename',\n comments: 'include.comments'\n };\n\n const targetsFile = path.resolve(file);\n if (!fs.statSync(targetsFile).isFile()) {\n throw Error('Targets file is not a file');\n }\n\n const lines = fs.readFileSync(targetsFile)\n .toString('utf-8')\n // Replace Windows line breaks with Unix ones and then split\n .replace(/\\r\\n/g, '\\n').split('\\n')\n .map((line) => line.trim());\n\n const currentTargets: { url: string; include?: RecursivePropsTo<DeepPartial<DownloaderIncludeOptions>, CLIOptionParserEntry>; }[] = [];\n for (let ln = 0; ln < lines.length; ln++) {\n const line = lines[ln];\n if (line === '' || line.startsWith('#')) {\n continue;\n }\n try {\n const match = Object.entries(includeKeys).find((e) => line.startsWith(e[1]));\n if (match) {\n const [ optName, matchKey ] = match;\n const eq = line.indexOf('=');\n const propValue = (eq >= matchKey.length ? line.substring(eq + 1) : '').trim();\n if (propValue) {\n const target = currentTargets.at(-1);\n if (target) {\n const entry: CLIOptionParserEntry = {\n key: matchKey,\n line: ln,\n src: 'tgt',\n value: propValue\n };\n if (!target.include) {\n target.include = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter || matchKey === includeKeys.postsPublishedBefore) {\n if (!target.include.postsPublished) {\n target.include.postsPublished = {};\n }\n if (matchKey === includeKeys.postsPublishedAfter) {\n target.include.postsPublished.after = entry;\n }\n else {\n target.include.postsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.productsPublishedAfter || matchKey === includeKeys.productsPublishedBefore) {\n if (!target.include.productsPublished) {\n target.include.productsPublished = {};\n }\n if (matchKey === includeKeys.productsPublishedAfter) {\n target.include.productsPublished.after = entry;\n }\n else {\n target.include.productsPublished.before = entry;\n }\n }\n else if (matchKey === includeKeys.imagesByFilename || matchKey === includeKeys.audioByFilename ||\n matchKey === includeKeys.attachmentsByFilename) {\n if (!target.include.mediaByFilename) {\n target.include.mediaByFilename = {};\n }\n switch (matchKey) {\n case includeKeys.imagesByFilename:\n target.include.mediaByFilename.images = entry;\n break;\n case includeKeys.audioByFilename:\n target.include.mediaByFilename.audio = entry;\n break;\n case includeKeys.attachmentsByFilename:\n target.include.mediaByFilename.attachments = entry;\n break;\n }\n }\n else {\n target.include[optName as keyof DownloaderIncludeOptions] = entry;\n }\n }\n }\n }\n else {\n const url = CLIOptionValidator.validateTargetURL(line);\n currentTargets.push({ url });\n }\n }\n catch (error: any) {\n const errMsg = error instanceof Error ? error.message : error;\n throw Error(`Error parsing targets file (line ${ln})${errMsg ? `: ${errMsg}` : ''}`);\n }\n }\n\n const result: CLITargetURLEntry[] = [];\n for (const target of currentTargets) {\n const v: CLITargetURLEntry = { url: target.url };\n if (target.include) {\n const includeOpts = ObjectHelper.clean(getCLIIncludeOptions(target), {\n deep: true, cleanNulls: true, cleanEmptyObjects: true\n });\n if (Object.entries(includeOpts).length > 0) {\n v.include = includeOpts;\n }\n }\n result.push(v);\n }\n\n return result;\n}\n"]}
|
|
@@ -44,7 +44,7 @@ const CONFIG_FILE_PROPS = {
|
|
|
44
44
|
allMediaVariants: 'include:all.media.variants',
|
|
45
45
|
mediaThumbnails: 'include:media.thumbnails',
|
|
46
46
|
imagesByFilename: 'include:images.by.filename',
|
|
47
|
-
audioByFilename: 'include
|
|
47
|
+
audioByFilename: 'include:audio.by.filename',
|
|
48
48
|
attachmentsByFilename: 'include:attachments.by.filename',
|
|
49
49
|
comments: 'include:comments'
|
|
50
50
|
},
|
|
@@ -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,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,sBAAsB;IAChC,YAAY,EAAE,2BAA2B;IACzC,kBAAkB,EAAE,iCAAiC;IACrD,UAAU,EAAE,yBAAyB;IACrC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,gBAAgB;IACxB,aAAa,EAAE;QACb,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,gCAAgC;KAC1C;IACD,cAAc,EAAE;QACd,KAAK,EAAE,8BAA8B;KACtC;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,oCAAoC;KAC9C;IACD,OAAO,EAAE;QACP,aAAa,EAAE,wBAAwB;QACvC,kBAAkB,EAAE,+BAA+B;QACnD,WAAW,EAAE,uBAAuB;QACpC,mBAAmB,EAAE,+BAA+B;QACpD,oBAAoB,EAAE,gCAAgC;QACtD,sBAAsB,EAAE,kCAAkC;QAC1D,uBAAuB,EAAE,mCAAmC;QAC5D,YAAY,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AAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACnG,IAAI;aACL,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;eA/JkB,gBAAgB","sourcesContent":["import ConfigParser from 'configparser';\nimport { type CLIOptionParserEntry, type CLIOptions } from './CLIOptions.js';\nimport { type DeepPartial, type RecursivePropsTo } from '../utils/Misc.js';\n\nconst CONFIG_FILE_PROPS = {\n targetURL: 'downloader:target.url',\n cookie: 'downloader:cookie',\n useStatusCache: 'downloader:use.status.cache',\n stopOn: 'downloader:stop.on',\n noPrompt: 'downloader:no.prompt',\n pathToFFmpeg: 'downloader:path.to.ffmpeg',\n maxVideoResolution: 'downloader:max.video.resolution',\n pathToDeno: 'downloader:path.to.deno',\n dryRun: 'downloader:dry.run',\n outDir: 'output:out.dir',\n dirNameFormat: {\n campaign: 'output:campaign.dir.name.format',\n content: 'output:content.dir.name.format'\n },\n filenameFormat: {\n media: 'output:media.filename.format'\n },\n fileExistsAction: {\n content: 'output:content.file.exists.action',\n info: 'output:info.file.exists.action',\n infoAPI: 'output:info.api.file.exists.action'\n },\n include: {\n lockedContent: 'include:locked.content',\n postsWithMediaType: 'include:posts.with.media.type',\n postsInTier: 'include:posts.in.tier',\n postsPublishedAfter: 'include:posts.published.after',\n postsPublishedBefore: 'include:posts.published.before',\n productsPublishedAfter: 'include:products.published.after',\n productsPublishedBefore: 'include:products.published.before',\n campaignInfo: 'include:campaign.info',\n contentInfo: 'include:content.info',\n previewMedia: 'include:preview.media',\n protectedMedia: 'include:protected.media',\n contentMedia: 'include:content.media',\n allMediaVariants: 'include:all.media.variants',\n mediaThumbnails: 'include:media.thumbnails',\n imagesByFilename: 'include:images.by.filename',\n audioByFilename: 'include.audio.by.filename',\n attachmentsByFilename: 'include:attachments.by.filename',\n comments: 'include:comments'\n },\n request: {\n maxRetries: 'request:max.retries',\n maxConcurrent: 'request:max.concurrent',\n minTime: 'request:min.time',\n proxy: {\n url: 'request:proxy.url',\n rejectUnauthorizedTLS: 'request:proxy.reject.unauthorized.tls'\n },\n userAgent: 'request:user.agent'\n },\n consoleLogger: {\n enabled: 'logger.console:enabled',\n logLevel: 'logger.console:log.level',\n include: {\n dateTime: 'logger.console:include.date.time',\n level: 'logger.console:include.level',\n originator: 'logger.console:include.originator',\n errorStack: 'logger.console:include.error.stack'\n },\n dateTimeFormat: 'logger.console:date.time.format',\n color: 'logger.console:color'\n },\n fileLogger: {\n enabled: ':enabled',\n logDir: ':log.dir',\n logFilename: ':log.filename',\n fileExistsAction: ':file.exists.action',\n logLevel: ':log.level',\n include: {\n dateTime: ':include.date.time',\n level: ':include.level',\n originator: ':include.originator',\n errorStack: ':include.error.stack'\n },\n dateTimeFormat: ':date.time.format',\n color: ':color'\n },\n embedDownloader: {\n exec: ':exec'\n }\n};\n\nexport type ConfigFileParseResult = RecursivePropsTo<DeepPartial<Omit<CLIOptions, 'targetURLs'>>, CLIOptionParserEntry> & {\n targetURLs?: CLIOptionParserEntry;\n};\n\nexport default class ConfigFileParser {\n\n static parse(file: string): ConfigFileParseResult {\n const parser = new ConfigParser();\n\n parser.read(file);\n\n const __getValue = (prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, prop);\n };\n\n return {\n targetURLs: __getValue(CONFIG_FILE_PROPS.targetURL),\n cookie: __getValue(CONFIG_FILE_PROPS.cookie),\n useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),\n stopOn: __getValue(CONFIG_FILE_PROPS.stopOn),\n pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),\n maxVideoResolution: __getValue(CONFIG_FILE_PROPS.maxVideoResolution),\n pathToDeno: __getValue(CONFIG_FILE_PROPS.pathToDeno),\n outDir: __getValue(CONFIG_FILE_PROPS.outDir),\n dirNameFormat: {\n campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),\n content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)\n },\n filenameFormat: {\n media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)\n },\n include: {\n lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),\n postsWithMediaType: __getValue(CONFIG_FILE_PROPS.include.postsWithMediaType),\n postsInTier: __getValue(CONFIG_FILE_PROPS.include.postsInTier),\n postsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.postsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.postsPublishedBefore),\n },\n productsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.productsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.productsPublishedBefore),\n },\n campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),\n contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),\n previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),\n contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),\n protectedMedia: __getValue(CONFIG_FILE_PROPS.include.protectedMedia),\n allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants),\n mediaThumbnails: __getValue(CONFIG_FILE_PROPS.include.mediaThumbnails),\n mediaByFilename: {\n images: __getValue(CONFIG_FILE_PROPS.include.imagesByFilename),\n audio: __getValue(CONFIG_FILE_PROPS.include.audioByFilename),\n attachments: __getValue(CONFIG_FILE_PROPS.include.attachmentsByFilename)\n },\n comments: __getValue(CONFIG_FILE_PROPS.include.comments)\n },\n request: {\n maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),\n maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),\n minTime: __getValue(CONFIG_FILE_PROPS.request.minTime),\n proxy: {\n url: __getValue(CONFIG_FILE_PROPS.request.proxy.url),\n rejectUnauthorizedTLS: __getValue(CONFIG_FILE_PROPS.request.proxy.rejectUnauthorizedTLS),\n },\n userAgent: __getValue(CONFIG_FILE_PROPS.request.userAgent),\n },\n fileExistsAction: {\n content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),\n info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),\n infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)\n },\n noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),\n dryRun: __getValue(CONFIG_FILE_PROPS.dryRun),\n consoleLogger: {\n enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),\n logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),\n include: {\n dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),\n level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),\n originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),\n errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),\n color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)\n },\n fileLoggers: this.#parseFileLoggerOptions(parser),\n embedDownloaders: this.#parseEmbedDownloaderOptions(parser)\n };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key, true)?.trim();\n if (value && value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1);\n }\n if (value) {\n return {\n src: 'cfg',\n section,\n key,\n value\n };\n }\n return undefined;\n }\n\n static #parseFileLoggerOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));\n\n const loggers = sections.reduce<NonNullable<ConfigFileParseResult['fileLoggers']>>((result, section) => {\n result.push({\n enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),\n logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),\n logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),\n fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),\n logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),\n include: {\n dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),\n level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),\n originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),\n errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),\n color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)\n });\n return result;\n }, []);\n\n return loggers.length > 0 ? loggers : undefined;\n }\n\n static #parseEmbedDownloaderOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('embed.downloader.'));\n const prefixLength = 'embed.downloader.'.length;\n const embedDownloaders = sections.reduce<NonNullable<ConfigFileParseResult['embedDownloaders']>>((result, section) => {\n const provider = section.substring(prefixLength).trim().toLowerCase();\n if (!provider) {\n throw Error('Config file section \\'embed.downloader.<provider>\\' is missing the provider name');\n }\n if (result.find((dl) => dl.provider?.value === provider)) {\n throw Error(`Duplicate config file section 'embed.downloader.${provider}`);\n }\n const exec = __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec);\n if (exec) {\n result.push({\n provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },\n exec\n });\n }\n return result;\n }, []);\n\n return embedDownloaders.length > 0 ? embedDownloaders : undefined;\n }\n}\n"]}
|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type CLIOptions } from './CLIOptions.js';\nimport { type DeepPartial, type RecursivePropsTo } from '../utils/Misc.js';\n\nconst CONFIG_FILE_PROPS = {\n targetURL: 'downloader:target.url',\n cookie: 'downloader:cookie',\n useStatusCache: 'downloader:use.status.cache',\n stopOn: 'downloader:stop.on',\n noPrompt: 'downloader:no.prompt',\n pathToFFmpeg: 'downloader:path.to.ffmpeg',\n maxVideoResolution: 'downloader:max.video.resolution',\n pathToDeno: 'downloader:path.to.deno',\n dryRun: 'downloader:dry.run',\n outDir: 'output:out.dir',\n dirNameFormat: {\n campaign: 'output:campaign.dir.name.format',\n content: 'output:content.dir.name.format'\n },\n filenameFormat: {\n media: 'output:media.filename.format'\n },\n fileExistsAction: {\n content: 'output:content.file.exists.action',\n info: 'output:info.file.exists.action',\n infoAPI: 'output:info.api.file.exists.action'\n },\n include: {\n lockedContent: 'include:locked.content',\n postsWithMediaType: 'include:posts.with.media.type',\n postsInTier: 'include:posts.in.tier',\n postsPublishedAfter: 'include:posts.published.after',\n postsPublishedBefore: 'include:posts.published.before',\n productsPublishedAfter: 'include:products.published.after',\n productsPublishedBefore: 'include:products.published.before',\n campaignInfo: 'include:campaign.info',\n contentInfo: 'include:content.info',\n previewMedia: 'include:preview.media',\n protectedMedia: 'include:protected.media',\n contentMedia: 'include:content.media',\n allMediaVariants: 'include:all.media.variants',\n mediaThumbnails: 'include:media.thumbnails',\n imagesByFilename: 'include:images.by.filename',\n audioByFilename: 'include:audio.by.filename',\n attachmentsByFilename: 'include:attachments.by.filename',\n comments: 'include:comments'\n },\n request: {\n maxRetries: 'request:max.retries',\n maxConcurrent: 'request:max.concurrent',\n minTime: 'request:min.time',\n proxy: {\n url: 'request:proxy.url',\n rejectUnauthorizedTLS: 'request:proxy.reject.unauthorized.tls'\n },\n userAgent: 'request:user.agent'\n },\n consoleLogger: {\n enabled: 'logger.console:enabled',\n logLevel: 'logger.console:log.level',\n include: {\n dateTime: 'logger.console:include.date.time',\n level: 'logger.console:include.level',\n originator: 'logger.console:include.originator',\n errorStack: 'logger.console:include.error.stack'\n },\n dateTimeFormat: 'logger.console:date.time.format',\n color: 'logger.console:color'\n },\n fileLogger: {\n enabled: ':enabled',\n logDir: ':log.dir',\n logFilename: ':log.filename',\n fileExistsAction: ':file.exists.action',\n logLevel: ':log.level',\n include: {\n dateTime: ':include.date.time',\n level: ':include.level',\n originator: ':include.originator',\n errorStack: ':include.error.stack'\n },\n dateTimeFormat: ':date.time.format',\n color: ':color'\n },\n embedDownloader: {\n exec: ':exec'\n }\n};\n\nexport type ConfigFileParseResult = RecursivePropsTo<DeepPartial<Omit<CLIOptions, 'targetURLs'>>, CLIOptionParserEntry> & {\n targetURLs?: CLIOptionParserEntry;\n};\n\nexport default class ConfigFileParser {\n\n static parse(file: string): ConfigFileParseResult {\n const parser = new ConfigParser();\n\n parser.read(file);\n\n const __getValue = (prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, prop);\n };\n\n return {\n targetURLs: __getValue(CONFIG_FILE_PROPS.targetURL),\n cookie: __getValue(CONFIG_FILE_PROPS.cookie),\n useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),\n stopOn: __getValue(CONFIG_FILE_PROPS.stopOn),\n pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),\n maxVideoResolution: __getValue(CONFIG_FILE_PROPS.maxVideoResolution),\n pathToDeno: __getValue(CONFIG_FILE_PROPS.pathToDeno),\n outDir: __getValue(CONFIG_FILE_PROPS.outDir),\n dirNameFormat: {\n campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),\n content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)\n },\n filenameFormat: {\n media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)\n },\n include: {\n lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),\n postsWithMediaType: __getValue(CONFIG_FILE_PROPS.include.postsWithMediaType),\n postsInTier: __getValue(CONFIG_FILE_PROPS.include.postsInTier),\n postsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.postsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.postsPublishedBefore),\n },\n productsPublished: {\n after: __getValue(CONFIG_FILE_PROPS.include.productsPublishedAfter),\n before: __getValue(CONFIG_FILE_PROPS.include.productsPublishedBefore),\n },\n campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),\n contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),\n previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),\n contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),\n protectedMedia: __getValue(CONFIG_FILE_PROPS.include.protectedMedia),\n allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants),\n mediaThumbnails: __getValue(CONFIG_FILE_PROPS.include.mediaThumbnails),\n mediaByFilename: {\n images: __getValue(CONFIG_FILE_PROPS.include.imagesByFilename),\n audio: __getValue(CONFIG_FILE_PROPS.include.audioByFilename),\n attachments: __getValue(CONFIG_FILE_PROPS.include.attachmentsByFilename)\n },\n comments: __getValue(CONFIG_FILE_PROPS.include.comments)\n },\n request: {\n maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),\n maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),\n minTime: __getValue(CONFIG_FILE_PROPS.request.minTime),\n proxy: {\n url: __getValue(CONFIG_FILE_PROPS.request.proxy.url),\n rejectUnauthorizedTLS: __getValue(CONFIG_FILE_PROPS.request.proxy.rejectUnauthorizedTLS),\n },\n userAgent: __getValue(CONFIG_FILE_PROPS.request.userAgent),\n },\n fileExistsAction: {\n content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),\n info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),\n infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)\n },\n noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),\n dryRun: __getValue(CONFIG_FILE_PROPS.dryRun),\n consoleLogger: {\n enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),\n logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),\n include: {\n dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),\n level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),\n originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),\n errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),\n color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)\n },\n fileLoggers: this.#parseFileLoggerOptions(parser),\n embedDownloaders: this.#parseEmbedDownloaderOptions(parser)\n };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key, true)?.trim();\n if (value && value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1);\n }\n if (value) {\n return {\n src: 'cfg',\n section,\n key,\n value\n };\n }\n return undefined;\n }\n\n static #parseFileLoggerOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));\n\n const loggers = sections.reduce<NonNullable<ConfigFileParseResult['fileLoggers']>>((result, section) => {\n result.push({\n enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),\n logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),\n logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),\n fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),\n logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),\n include: {\n dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),\n level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),\n originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),\n errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),\n color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)\n });\n return result;\n }, []);\n\n return loggers.length > 0 ? loggers : undefined;\n }\n\n static #parseEmbedDownloaderOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('embed.downloader.'));\n const prefixLength = 'embed.downloader.'.length;\n const embedDownloaders = sections.reduce<NonNullable<ConfigFileParseResult['embedDownloaders']>>((result, section) => {\n const provider = section.substring(prefixLength).trim().toLowerCase();\n if (!provider) {\n throw Error('Config file section \\'embed.downloader.<provider>\\' is missing the provider name');\n }\n if (result.find((dl) => dl.provider?.value === provider)) {\n throw Error(`Duplicate config file section 'embed.downloader.${provider}`);\n }\n const exec = __getValue(section, CONFIG_FILE_PROPS.embedDownloader.exec);\n if (exec) {\n result.push({\n provider: { src: 'cfg', section: `embed.downloader.${provider}`, key: 'provider', value: provider },\n exec\n });\n }\n return result;\n }, []);\n\n return embedDownloaders.length > 0 ? embedDownloaders : undefined;\n }\n}\n"]}
|
|
@@ -252,7 +252,7 @@ class Downloader extends EventEmitter {
|
|
|
252
252
|
if (downloader instanceof PostDownloader) {
|
|
253
253
|
if (typeof params === 'object' && params.campaignId) {
|
|
254
254
|
const { json } = await downloader.fetchCampaign(params.campaignId, signal);
|
|
255
|
-
const parser = new PostParser(options instanceof Logger ? options : options?.logger);
|
|
255
|
+
const parser = new PostParser(downloader.getFetcher(), options instanceof Logger ? options : options?.logger);
|
|
256
256
|
return parser.parseCampaignAPIResponse(json);
|
|
257
257
|
}
|
|
258
258
|
return downloader.__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,CAAC,aAAa,EAAE,OAAO,CAAC;IAC5D,IAAI,oBAAoB,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,4BAA4B,CAAC,oBAAoB,CAAC,CAAC;QACzF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,KAAK,CAAC,kCAAkC,oBAAoB,iCAAiC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QACxH,CAAC;IACH,CAAC;IACD,MAAM,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC;IAC1D,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC;QACvF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,KAAK,CAAC,0BAA0B,mBAAmB,iCAAiC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QAC/G,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;eAtV2B,UAAU","sourcesContent":["import fs from 'fs';\nimport { EventEmitter } from 'events';\nimport deepFreeze from 'deep-freeze';\nimport Fetcher from '../utils/Fetcher.js';\nimport Bootstrap, { type PostDownloaderBootstrapData, type ProductDownloaderBootstrapData, type DownloaderBootstrapData, type DownloaderType } from './Bootstrap.js';\nimport { type DownloaderInit, type DownloaderOptions, type FileExistsAction, getDownloaderInit } from './DownloaderOptions.js';\nimport { type DownloaderEvent, type DownloaderEventPayloadOf } from './DownloaderEvent.js';\nimport {type LogLevel} from '../utils/logging/Logger.js';\nimport Logger from '../utils/logging/Logger.js';\nimport { commonLog } from '../utils/logging/Logger.js';\nimport { type Campaign } from '../entities/Campaign.js';\nimport FSHelper, { type WriteTextFileResult } from '../utils/FSHelper.js';\nimport DownloadTaskBatch from './task/DownloadTaskBatch.js';\nimport { type IDownloadTask } from './task/DownloadTask.js';\nimport DownloadTaskFactory from './task/DownloadTaskFactory.js';\nimport FilenameFormatHelper from '../utils/FilenameFormatHelper.js';\nimport { type Downloadable } from '../entities/Downloadable.js';\nimport { generateCampaignSummary } from './templates/CampaignInfo.js';\nimport path from 'path';\nimport URLHelper from '../utils/URLHelper.js';\nimport ffmpeg from 'fluent-ffmpeg';\nimport InnertubeLoader from '../utils/yt/InnertubeLoader.js';\nimport FFmpegDownloadTaskBase from './task/FFmpegDownloadTaskBase.js';\nimport ExternalDownloaderTask from './task/ExternalDownloaderTask.js';\nimport DB, { type DBInstance } from '../browse/db/index.js';\nimport PostParser from '../parsers/PostParser.js';\nimport { isDenoInstalled } from '../utils/Misc.js';\nimport { type Collection } from '../entities/Post.js';\n\nexport type DownloaderConfig<T extends DownloaderType> =\n DownloaderInit &\n DownloaderBootstrapData<T>;\n\nexport interface DownloaderStartParams {\n signal?: AbortSignal;\n}\n\nexport type GetCampaignParams = \n string |\n { userId: string; vanity?: never, campaignId?: never; } |\n { userId?: never; vanity: string, campaignId?: never; } |\n { vanity?: never; userId?: never; campaignId: string; };\n\ninterface CreateDownloadTaskParams<T extends DownloaderType> {\n target: Downloadable[];\n targetName: string;\n src: T | Campaign | Collection,\n dirs: {\n campaign: string | null;\n main: string;\n thumbnails: string | null;\n };\n fileExistsAction: FileExistsAction;\n isAttachment?: boolean;\n ignoreCreateTaskErrors?: boolean;\n}\n\nexport default abstract class Downloader<T extends DownloaderType> extends EventEmitter {\n\n abstract name: string;\n\n protected fetcher: Fetcher;\n protected fsHelper: FSHelper;\n protected config: DownloaderConfig<T>;\n protected logger?: Logger | null;\n protected db: () => Promise<DBInstance>;\n #dbPromise: Promise<DBInstance> | null;\n\n #hasEmittedEndEventOnAbort: boolean;\n\n constructor(config: DownloaderConfig<T>, db: () => Promise<DBInstance>, logger?: Logger | null) {\n super();\n\n this.config = config;\n this.fetcher = new Fetcher(this.config, logger);\n this.fsHelper = new FSHelper(this.config, logger);\n this.#dbPromise = null;\n this.db = async () => {\n if (!this.#dbPromise) {\n this.#dbPromise = db();\n }\n return this.#dbPromise;\n }\n this.logger = logger;\n\n if (this.config.pathToFFmpeg) {\n ffmpeg.setFfmpegPath(this.config.pathToFFmpeg);\n }\n\n InnertubeLoader.setLogger(this.logger);\n if (this.config.pathToYouTubeCredentials) {\n InnertubeLoader.setCredentialsFile(this.config.pathToYouTubeCredentials);\n }\n\n this.#hasEmittedEndEventOnAbort = false;\n }\n\n protected createDownloadTaskBatch(\n name: string,\n signal?: AbortSignal,\n ...createTasks: Array<CreateDownloadTaskParams<T> | null>\n ): Promise<{ batch: DownloadTaskBatch; errorCount: number; }> {\n\n const __getDownloadIdString = (task: IDownloadTask, batch: DownloadTaskBatch) => {\n let result = `#${batch.id}.${task.id}`;\n if (task.retryCount > 0) {\n result += `-r${task.retryCount}`;\n }\n return result;\n };\n\n const batch = new DownloadTaskBatch({\n name,\n fetcher: this.fetcher,\n limiter: this.config.request,\n logger: this.logger\n });\n\n batch.on('taskStart', ({task}) => {\n const retryOrBeginStr = task.retryCount > 0 ? 'retry' : 'begin';\n const isExternal = task instanceof ExternalDownloaderTask;\n const destStr = isExternal ? ' -> Unknown destination (external process)' : task.resolvedDestFilename ? ` -> ${task.resolvedDestFilename}` : '';\n this.log('info', `Download ${retryOrBeginStr} (${__getDownloadIdString(task, batch)}): [type: ${task.srcEntity.type}; ID: #${task.srcEntity.id}]${destStr}`);\n if (task instanceof FFmpegDownloadTaskBase) {\n const retryOrBeginStr = task.retryCount > 0 ? 'Retry' : 'Begin';\n this.log('info', `${retryOrBeginStr} FFmpeg task (${__getDownloadIdString(task, batch)}): ${task.commandLine}`);\n }\n });\n\n batch.on('taskComplete', ({task}) => {\n const isExternal = task instanceof ExternalDownloaderTask;\n const destStr = isExternal ? ': Unknown destination (external process)' : task.resolvedDestPath ? `: \"${task.resolvedDestPath}\"` : '';\n this.log('info', `Download complete (${__getDownloadIdString(task, batch)})${destStr}`);\n });\n\n batch.on('taskError', ({error, willRetry}) => {\n const { task, cause, message } = error;\n const retryStr = willRetry ? '- will retry' : '';\n this.log('error', `Download error (${__getDownloadIdString(task, batch)}):`, cause || message, `(${task.src})`, retryStr);\n });\n\n batch.on('taskAbort', ({task}) => {\n this.log('warn', `Download aborted (${__getDownloadIdString(task, batch)})`);\n });\n\n batch.on('taskSkip', ({task, reason}) => {\n this.log('warn', `Download skipped (${__getDownloadIdString(task, batch)}): ${reason.message}`);\n });\n\n batch.on('taskSpawn', ({origin, spawn}) => {\n this.log('info', `Download spawned: #${batch.id}.${origin.id} -> #${batch.id}.${spawn.id}`);\n });\n\n /**\n * Uncomment this block to log download progress\n\n batch.on('taskProgress', ({task, progress}) => {\n if (progress) {\n if (progress.length) {\n this.log('info', `Download progress (${__getDownloadIdString(task, batch)}): ${progress.lengthDownloaded} / ${progress.length} ${progress.lengthUnit}s / ${progress.percent}% (${progress.speed} kB/s)`,);\n }\n else {\n this.log('info', `Download progress (${__getDownloadIdString(task, batch)}): ${progress.lengthDownloaded} / ? ${progress.lengthUnit}s (${progress.speed} kB/s)`,);\n }\n }\n else {\n this.log('warn', `Download progress not available (${__getDownloadIdString(task, batch)})`);\n }\n });\n\n */\n\n batch.on('complete', () => {\n const total = batch.getTasks().length;\n const completed = batch.getTasks('completed').length;\n const error = batch.getTasks('error').length;\n const aborted = batch.getTasks('aborted').length;\n const skipped = batch.getTasks('skipped').length;\n const counts = [\n `${total} downloads`,\n `${completed} completed`,\n `${error} errors`,\n `${skipped} skipped`,\n `${aborted} aborted`\n ].join('; ');\n this.log('info', `Download batch complete (#${batch.id}): ${counts}`);\n });\n\n return this.addToDownloadTaskBatch(batch, signal, ...createTasks);\n }\n\n protected async addToDownloadTaskBatch(\n batch: DownloadTaskBatch,\n signal?: AbortSignal,\n ...createTasks: Array<CreateDownloadTaskParams<T> | null>\n ) {\n let failedCreateTaskCount = 0;\n for (const task of createTasks) {\n if (!task) {\n continue;\n }\n const { target, targetName, src, dirs } = task;\n this.log('info', `Create download tasks for ${targetName}`);\n if (task.target.length === 0) {\n this.log('warn', `No items in ${targetName}`);\n continue;\n }\n let ensureDirs: string[] = [];\n for (const tt of target) {\n try {\n const tasks = await DownloadTaskFactory.createFromDownloadable({\n config: this.config,\n dirs,\n item: tt,\n src,\n fetcher: this.fetcher,\n fileExistsAction: task.fileExistsAction,\n isAttachment: task.isAttachment,\n limiter: batch.limiter,\n signal,\n logger: this.logger\n });\n\n if (signal?.aborted) {\n return { batch, errorCount: failedCreateTaskCount };\n }\n\n // Filter out tasks that are DOA (errors that occurred in DownloadTask.create())\n for (const task of tasks) {\n if (task.doa) {\n this.log('error', `Failed to create download task for item #${tt.id} in ${targetName}:`, task.doa.msg, task.doa.cause);\n failedCreateTaskCount++;\n }\n }\n const createdTasks = tasks.filter((task) => !task.doa);\n batch.addTasks(createdTasks);\n ensureDirs = createdTasks.reduce<string[]>((result, task) => {\n const dir = task.resolvedDestPath ? path.dirname(task.resolvedDestPath) : null;\n if (dir && !result.includes(dir)) {\n result.push(dir);\n }\n return result;\n }, ensureDirs);\n }\n catch (error) {\n if (signal?.aborted) {\n this.log('warn', 'Operation aborted');\n return { batch, errorCount: failedCreateTaskCount };\n }\n if (!task.ignoreCreateTaskErrors) {\n this.log('error', `Failed to create download task(s) for item #${tt.id} in ${targetName}:`, error);\n failedCreateTaskCount++;\n }\n }\n }\n for (const dir of ensureDirs) {\n this.fsHelper.createDir(dir);\n }\n }\n if (failedCreateTaskCount > 0) {\n this.log('warn', `${failedCreateTaskCount} items could not be processed for downloading`);\n }\n return { batch, errorCount: failedCreateTaskCount };\n }\n\n async start(params: DownloaderStartParams) {\n try {\n await this.doStart(params);\n }\n finally {\n InnertubeLoader.reset();\n }\n }\n\n abstract doStart(params: DownloaderStartParams): Promise<void>;\n\n static async getInstance(\n target: string | ProductDownloaderBootstrapData | PostDownloaderBootstrapData,\n options?: DownloaderOptions\n ) {\n const bootstrap = typeof target === 'string' ? Bootstrap.getDownloaderBootstrapDataByURL(target) : target;\n if (!bootstrap) {\n throw Error('Could not determine downloader type from URL');\n }\n this.#validateOptions(options);\n\n const config = {\n ...bootstrap,\n ...getDownloaderInit(options)\n };\n const logger = options?.logger;\n const fsHelper = new FSHelper(config, logger);\n const db = () => DB.getInstance(fsHelper.getDBFilePath(), config.dryRun, logger);\n \n switch (config.type) {\n case 'product': {\n const ProductDownloader = (await import('./ProductDownloader.js')).default;\n return new ProductDownloader(config, db, logger);\n }\n case 'post': {\n const PostDownloader = (await import('./PostDownloader.js')).default;\n return new PostDownloader(config, db, logger);\n }\n }\n }\n\n static async getCampaign(\n params: GetCampaignParams,\n signal?: AbortSignal,\n options?: Logger | null | Pick<DownloaderOptions, 'cookie' | 'request' | 'logger'>\n ) {\n // Backwards compatibility - if 'params' is string type, then it is vanity\n let url: string;\n if (typeof params === 'string') {\n url = URLHelper.constructUserPostsURL({ vanity: params });\n }\n else if (params.userId || params.vanity) {\n url = URLHelper.constructUserPostsURL(params);\n }\n else {\n // Sole purpose of passing 'dummy' vanity is to create the PostDownloader instance\n url = URLHelper.constructUserPostsURL({ vanity: 'dummy' });\n }\n const downloader = await this.getInstance(\n url,\n options instanceof Logger ? { logger: options } : (options || undefined)\n );\n const PostDownloader = (await import('./PostDownloader.js')).default;\n if (downloader instanceof PostDownloader) {\n if (typeof params === 'object' && params.campaignId) {\n const { json } = await downloader.fetchCampaign(params.campaignId, signal);\n const parser = new PostParser(options instanceof Logger ? options : options?.logger);\n return parser.parseCampaignAPIResponse(json);\n }\n return downloader.__getCampaign(signal);\n }\n throw Error('Type mismatch: PostDownloader expected');\n }\n\n static #validateOptions(options?: DownloaderOptions) {\n if (!options) {\n return true;\n }\n\n // Check FFmpeg path exists\n if (options.pathToFFmpeg) {\n if (!fs.existsSync(options.pathToFFmpeg)) {\n throw Error(`Path to FFmpeg executable \"${options.pathToFFmpeg}\" does not exist`);\n }\n else if (!fs.lstatSync(options.pathToFFmpeg).isFile()) {\n throw Error(`Path to FFmpeg executable \"${options.pathToFFmpeg}\" does not point to a file`);\n }\n }\n\n // Check Deno path exists and startable\n if (options.pathToDeno) {\n if (!fs.existsSync(options.pathToDeno)) {\n throw Error(`Path to Deno executable \"${options.pathToDeno}\" does not exist`);\n }\n else if (!fs.lstatSync(options.pathToDeno).isFile()) {\n throw Error(`Path to Deno executable \"${options.pathToDeno}\" does not point to a file`);\n }\n const di = isDenoInstalled(options.pathToDeno);\n if (!di.installed) {\n throw Error(`Could not start Deno executable \"${options.pathToDeno}\"`, { cause: di.error });\n }\n }\n\n // Check outDir is a directory\n if (options.outDir) {\n if (fs.existsSync(options.outDir) && !fs.lstatSync(options.outDir).isDirectory()) {\n throw Error(`\"${options.outDir}\" is not a directory`);\n }\n }\n\n // Check formats are valid\n const campaignDirNameFormat = options.dirNameFormat?.campaign;\n if (campaignDirNameFormat) {\n const validate = FilenameFormatHelper.validateCampaignDirNameFormat(campaignDirNameFormat);\n if (!validate.validateOK) {\n throw Error(`Campaign directory name format '${campaignDirNameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n const contentDirNameFormat = options.dirNameFormat?.content;\n if (contentDirNameFormat) {\n const validate = FilenameFormatHelper.validateContentDirNameFormat(contentDirNameFormat);\n if (!validate.validateOK) {\n throw Error(`Content directory name format '${contentDirNameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n const mediaFilenameFormat = options.filenameFormat?.media;\n if (mediaFilenameFormat) {\n const validate = FilenameFormatHelper.validateMediaFilenameFormat(mediaFilenameFormat);\n if (!validate.validateOK) {\n throw Error(`Media filename format '${mediaFilenameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n\n return true;\n }\n\n protected async saveCampaignInfo(campaign: Campaign | null, signal?: AbortSignal) {\n const db = await this.db();\n if (!this.config.include.campaignInfo) {\n if (campaign) {\n db.saveCampaign(campaign, new Date());\n }\n return;\n }\n\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n let batch: DownloadTaskBatch | null = null;\n const abortHandler = () => {\n void (async () => {\n if (batch) {\n await batch.abort();\n }\n })();\n };\n if (signal) {\n signal.addEventListener('abort', abortHandler, { once: true });\n }\n\n if (!campaign) {\n this.log('warn', 'Skipped saving campaign info: target unavailable');\n return;\n }\n\n this.log('info', `Save campaign info #${campaign.id}`);\n this.emit('targetBegin', { target: campaign });\n this.emit('phaseBegin', { target: campaign, phase: 'saveInfo' });\n\n // Step 1: create campaign directories\n const campaignDirs = this.fsHelper.getCampaignDirs(campaign);\n this.log('debug', 'Campaign directories: ', campaignDirs);\n this.fsHelper.createDir(campaignDirs.root);\n this.fsHelper.createDir(campaignDirs.info);\n\n // Step 2: save summary and raw json\n const summary = generateCampaignSummary(campaign);\n const summaryFile = path.resolve(campaignDirs.info, 'info.txt');\n const saveSummaryResult = await this.fsHelper.writeTextFile(summaryFile, summary, this.config.fileExistsAction.info);\n this.logWriteTextFileResult(saveSummaryResult, campaign, 'campaign summary');\n\n // Campaign / creator raw data might not be complete. Fetch directly from API.\n // Strictly speaking, we should check for 'error' in results, but since it's not going to be fatal we'll just skip it.\n const { json: fetchedCampaignAPIData } = await this.fetchCampaign(campaign.id, signal);\n const { json: fetchedCreatorAPIData } = campaign.creator ? await this.fetchUser(campaign.creator.id, signal) : { json: null };\n\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n const campaignRawFile = path.resolve(campaignDirs.info, 'campaign-api.json');\n const saveCampaignRawResult = await this.fsHelper.writeTextFile(\n campaignRawFile, fetchedCampaignAPIData || campaign.raw, this.config.fileExistsAction.infoAPI);\n this.logWriteTextFileResult(saveCampaignRawResult, campaign, 'campaign API data');\n\n if (campaign.creator) {\n const creatorRawFile = path.resolve(campaignDirs.info, 'creator-api.json');\n const saveCreatorRawResult = await this.fsHelper.writeTextFile(\n creatorRawFile, fetchedCreatorAPIData || campaign.creator.raw, this.config.fileExistsAction.infoAPI);\n this.logWriteTextFileResult(saveCreatorRawResult, campaign.creator, 'creator API data');\n }\n\n this.emit('phaseEnd', { target: campaign, phase: 'saveInfo' });\n\n // Step 3: download campaign media items\n this.emit('phaseBegin', { target: campaign, phase: 'saveMedia' });\n const campaignMedia: Downloadable[] = [\n campaign.avatarImage,\n campaign.coverPhoto\n ];\n if (campaign.creator) {\n campaignMedia.push(\n campaign.creator.image,\n campaign.creator.thumbnail\n );\n }\n for (const reward of campaign.rewards) {\n if (reward.image) {\n campaignMedia.push(reward.image);\n }\n }\n batch = (await this.createDownloadTaskBatch(\n `Campaign #${campaign.id} (${campaign.name})`,\n signal,\n {\n target: campaignMedia,\n targetName: `campaign #${campaign.id} -> images`,\n src: campaign,\n dirs: {\n campaign: campaignDirs.root,\n main: campaignDirs.info,\n thumbnails: null\n },\n fileExistsAction: this.config.fileExistsAction.info\n }\n )).batch;\n if (this.checkAbortSignal(signal)) {\n return;\n }\n batch.prestart();\n this.emit('phaseBegin', { target: campaign, phase: 'batchDownload', batch });\n await batch.start();\n await batch.destroy();\n this.emit('phaseEnd', { target: campaign, phase: 'batchDownload' });\n this.emit('phaseEnd', { target: campaign, phase: 'saveMedia' });\n\n if (signal) {\n signal.removeEventListener('abort', abortHandler);\n }\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n // Step 4: save to DB\n db.saveCampaign(campaign, new Date());\n\n // Done\n this.log('info', 'Done saving campaign info');\n this.emit('targetEnd', { target: campaign, isSkipped: false });\n }\n\n protected log(level: LogLevel, ...msg: any[]) {\n commonLog(this.logger, level, this.name, ...msg);\n }\n\n getConfig(ro: false): DownloaderConfig<T>;\n getConfig(ro?: true): deepFreeze.DeepReadonly<DownloaderConfig<T>>;\n getConfig(ro = true) {\n return ro ? deepFreeze(this.config) : this.config;\n }\n\n protected checkAbortSignal(signal: AbortSignal | undefined) {\n if (signal && signal.aborted) {\n if (!this.#hasEmittedEndEventOnAbort) {\n this.emit('end', { aborted: true, message: 'Download aborted' });\n this.#hasEmittedEndEventOnAbort = true;\n }\n return true;\n }\n return false;\n }\n\n protected logWriteTextFileResult(result: WriteTextFileResult, target: {id: string}, targetName: string) {\n switch (result.status) {\n case 'completed':\n this.log('info', `Saved ${targetName} to \"${result.filePath}\"`);\n break;\n case 'skipped':\n this.log('warn', `Skipped saving ${targetName} #${target.id}: ${result.message}`);\n break;\n case 'error':\n this.log('error', `Error saving ${targetName} #${target.id} to \"${result.filePath}\":`, result.error);\n }\n }\n\n protected async commonFetchAPI(url: string, signal?: AbortSignal) {\n let json, requestAPIError: any;\n try {\n json = (await this.fetcher.get({ url, type: 'json', maxRetries: this.config.request.maxRetries, signal })).json;\n }\n catch (error) {\n if (signal?.aborted) {\n this.log('warn', 'API request aborted');\n }\n else {\n this.log('error', `Error requesting API URL \"${url}\": `, error);\n requestAPIError = error;\n }\n json = null;\n }\n return { json, error: requestAPIError };\n }\n\n protected fetchCampaign(campaignId: string, signal?: AbortSignal) {\n const url = URLHelper.constructCampaignAPIURL(campaignId);\n this.log('debug', `Fetch campaign data from API URL \"${url}\"`);\n return this.commonFetchAPI(url, signal);\n }\n\n protected fetchUser(userId: string, signal?: AbortSignal) {\n const url = URLHelper.constructUserAPIURL(userId);\n this.log('debug', `Fetch user data from API URL \"${url}\"`);\n return this.commonFetchAPI(url, signal);\n }\n\n protected async closeDB() {\n if (this.#dbPromise) {\n (await this.#dbPromise).close();\n this.#dbPromise = null;\n }\n }\n\n getFetcher() {\n return this.fetcher;\n }\n\n on<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n on(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.on(event, listener);\n }\n\n once<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n once(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.once(event, listener);\n }\n\n off<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n off(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.off(event, listener);\n }\n\n emit<T extends DownloaderEvent>(event: T, args: DownloaderEventPayloadOf<T>): boolean;\n emit(event: string | symbol, ...args: any[]): boolean {\n return super.emit(event, ...args);\n }\n}\n"]}
|
|
1
|
+
{"version":3,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AO,CAAC;IAC5D,IAAI,oBAAoB,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,4BAA4B,CAAC,oBAAoB,CAAC,CAAC;QACzF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,KAAK,CAAC,kCAAkC,oBAAoB,iCAAiC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QACxH,CAAC;IACH,CAAC;IACD,MAAM,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC;IAC1D,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC;QACvF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,KAAK,CAAC,0BAA0B,mBAAmB,iCAAiC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;QAC/G,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;eAtV2B,UAAU","sourcesContent":["import fs from 'fs';\nimport { EventEmitter } from 'events';\nimport deepFreeze from 'deep-freeze';\nimport Fetcher from '../utils/Fetcher.js';\nimport Bootstrap, { type PostDownloaderBootstrapData, type ProductDownloaderBootstrapData, type DownloaderBootstrapData, type DownloaderType } from './Bootstrap.js';\nimport { type DownloaderInit, type DownloaderOptions, type FileExistsAction, getDownloaderInit } from './DownloaderOptions.js';\nimport { type DownloaderEvent, type DownloaderEventPayloadOf } from './DownloaderEvent.js';\nimport {type LogLevel} from '../utils/logging/Logger.js';\nimport Logger from '../utils/logging/Logger.js';\nimport { commonLog } from '../utils/logging/Logger.js';\nimport { type Campaign } from '../entities/Campaign.js';\nimport FSHelper, { type WriteTextFileResult } from '../utils/FSHelper.js';\nimport DownloadTaskBatch from './task/DownloadTaskBatch.js';\nimport { type IDownloadTask } from './task/DownloadTask.js';\nimport DownloadTaskFactory from './task/DownloadTaskFactory.js';\nimport FilenameFormatHelper from '../utils/FilenameFormatHelper.js';\nimport { type Downloadable } from '../entities/Downloadable.js';\nimport { generateCampaignSummary } from './templates/CampaignInfo.js';\nimport path from 'path';\nimport URLHelper from '../utils/URLHelper.js';\nimport ffmpeg from 'fluent-ffmpeg';\nimport InnertubeLoader from '../utils/yt/InnertubeLoader.js';\nimport FFmpegDownloadTaskBase from './task/FFmpegDownloadTaskBase.js';\nimport ExternalDownloaderTask from './task/ExternalDownloaderTask.js';\nimport DB, { type DBInstance } from '../browse/db/index.js';\nimport PostParser from '../parsers/PostParser.js';\nimport { isDenoInstalled } from '../utils/Misc.js';\nimport { type Collection } from '../entities/Post.js';\n\nexport type DownloaderConfig<T extends DownloaderType> =\n DownloaderInit &\n DownloaderBootstrapData<T>;\n\nexport interface DownloaderStartParams {\n signal?: AbortSignal;\n}\n\nexport type GetCampaignParams = \n string |\n { userId: string; vanity?: never, campaignId?: never; } |\n { userId?: never; vanity: string, campaignId?: never; } |\n { vanity?: never; userId?: never; campaignId: string; };\n\ninterface CreateDownloadTaskParams<T extends DownloaderType> {\n target: Downloadable[];\n targetName: string;\n src: T | Campaign | Collection,\n dirs: {\n campaign: string | null;\n main: string;\n thumbnails: string | null;\n };\n fileExistsAction: FileExistsAction;\n isAttachment?: boolean;\n ignoreCreateTaskErrors?: boolean;\n}\n\nexport default abstract class Downloader<T extends DownloaderType> extends EventEmitter {\n\n abstract name: string;\n\n protected fetcher: Fetcher;\n protected fsHelper: FSHelper;\n protected config: DownloaderConfig<T>;\n protected logger?: Logger | null;\n protected db: () => Promise<DBInstance>;\n #dbPromise: Promise<DBInstance> | null;\n\n #hasEmittedEndEventOnAbort: boolean;\n\n constructor(config: DownloaderConfig<T>, db: () => Promise<DBInstance>, logger?: Logger | null) {\n super();\n\n this.config = config;\n this.fetcher = new Fetcher(this.config, logger);\n this.fsHelper = new FSHelper(this.config, logger);\n this.#dbPromise = null;\n this.db = async () => {\n if (!this.#dbPromise) {\n this.#dbPromise = db();\n }\n return this.#dbPromise;\n }\n this.logger = logger;\n\n if (this.config.pathToFFmpeg) {\n ffmpeg.setFfmpegPath(this.config.pathToFFmpeg);\n }\n\n InnertubeLoader.setLogger(this.logger);\n if (this.config.pathToYouTubeCredentials) {\n InnertubeLoader.setCredentialsFile(this.config.pathToYouTubeCredentials);\n }\n\n this.#hasEmittedEndEventOnAbort = false;\n }\n\n protected createDownloadTaskBatch(\n name: string,\n signal?: AbortSignal,\n ...createTasks: Array<CreateDownloadTaskParams<T> | null>\n ): Promise<{ batch: DownloadTaskBatch; errorCount: number; }> {\n\n const __getDownloadIdString = (task: IDownloadTask, batch: DownloadTaskBatch) => {\n let result = `#${batch.id}.${task.id}`;\n if (task.retryCount > 0) {\n result += `-r${task.retryCount}`;\n }\n return result;\n };\n\n const batch = new DownloadTaskBatch({\n name,\n fetcher: this.fetcher,\n limiter: this.config.request,\n logger: this.logger\n });\n\n batch.on('taskStart', ({task}) => {\n const retryOrBeginStr = task.retryCount > 0 ? 'retry' : 'begin';\n const isExternal = task instanceof ExternalDownloaderTask;\n const destStr = isExternal ? ' -> Unknown destination (external process)' : task.resolvedDestFilename ? ` -> ${task.resolvedDestFilename}` : '';\n this.log('info', `Download ${retryOrBeginStr} (${__getDownloadIdString(task, batch)}): [type: ${task.srcEntity.type}; ID: #${task.srcEntity.id}]${destStr}`);\n if (task instanceof FFmpegDownloadTaskBase) {\n const retryOrBeginStr = task.retryCount > 0 ? 'Retry' : 'Begin';\n this.log('info', `${retryOrBeginStr} FFmpeg task (${__getDownloadIdString(task, batch)}): ${task.commandLine}`);\n }\n });\n\n batch.on('taskComplete', ({task}) => {\n const isExternal = task instanceof ExternalDownloaderTask;\n const destStr = isExternal ? ': Unknown destination (external process)' : task.resolvedDestPath ? `: \"${task.resolvedDestPath}\"` : '';\n this.log('info', `Download complete (${__getDownloadIdString(task, batch)})${destStr}`);\n });\n\n batch.on('taskError', ({error, willRetry}) => {\n const { task, cause, message } = error;\n const retryStr = willRetry ? '- will retry' : '';\n this.log('error', `Download error (${__getDownloadIdString(task, batch)}):`, cause || message, `(${task.src})`, retryStr);\n });\n\n batch.on('taskAbort', ({task}) => {\n this.log('warn', `Download aborted (${__getDownloadIdString(task, batch)})`);\n });\n\n batch.on('taskSkip', ({task, reason}) => {\n this.log('warn', `Download skipped (${__getDownloadIdString(task, batch)}): ${reason.message}`);\n });\n\n batch.on('taskSpawn', ({origin, spawn}) => {\n this.log('info', `Download spawned: #${batch.id}.${origin.id} -> #${batch.id}.${spawn.id}`);\n });\n\n /**\n * Uncomment this block to log download progress\n\n batch.on('taskProgress', ({task, progress}) => {\n if (progress) {\n if (progress.length) {\n this.log('info', `Download progress (${__getDownloadIdString(task, batch)}): ${progress.lengthDownloaded} / ${progress.length} ${progress.lengthUnit}s / ${progress.percent}% (${progress.speed} kB/s)`,);\n }\n else {\n this.log('info', `Download progress (${__getDownloadIdString(task, batch)}): ${progress.lengthDownloaded} / ? ${progress.lengthUnit}s (${progress.speed} kB/s)`,);\n }\n }\n else {\n this.log('warn', `Download progress not available (${__getDownloadIdString(task, batch)})`);\n }\n });\n\n */\n\n batch.on('complete', () => {\n const total = batch.getTasks().length;\n const completed = batch.getTasks('completed').length;\n const error = batch.getTasks('error').length;\n const aborted = batch.getTasks('aborted').length;\n const skipped = batch.getTasks('skipped').length;\n const counts = [\n `${total} downloads`,\n `${completed} completed`,\n `${error} errors`,\n `${skipped} skipped`,\n `${aborted} aborted`\n ].join('; ');\n this.log('info', `Download batch complete (#${batch.id}): ${counts}`);\n });\n\n return this.addToDownloadTaskBatch(batch, signal, ...createTasks);\n }\n\n protected async addToDownloadTaskBatch(\n batch: DownloadTaskBatch,\n signal?: AbortSignal,\n ...createTasks: Array<CreateDownloadTaskParams<T> | null>\n ) {\n let failedCreateTaskCount = 0;\n for (const task of createTasks) {\n if (!task) {\n continue;\n }\n const { target, targetName, src, dirs } = task;\n this.log('info', `Create download tasks for ${targetName}`);\n if (task.target.length === 0) {\n this.log('warn', `No items in ${targetName}`);\n continue;\n }\n let ensureDirs: string[] = [];\n for (const tt of target) {\n try {\n const tasks = await DownloadTaskFactory.createFromDownloadable({\n config: this.config,\n dirs,\n item: tt,\n src,\n fetcher: this.fetcher,\n fileExistsAction: task.fileExistsAction,\n isAttachment: task.isAttachment,\n limiter: batch.limiter,\n signal,\n logger: this.logger\n });\n\n if (signal?.aborted) {\n return { batch, errorCount: failedCreateTaskCount };\n }\n\n // Filter out tasks that are DOA (errors that occurred in DownloadTask.create())\n for (const task of tasks) {\n if (task.doa) {\n this.log('error', `Failed to create download task for item #${tt.id} in ${targetName}:`, task.doa.msg, task.doa.cause);\n failedCreateTaskCount++;\n }\n }\n const createdTasks = tasks.filter((task) => !task.doa);\n batch.addTasks(createdTasks);\n ensureDirs = createdTasks.reduce<string[]>((result, task) => {\n const dir = task.resolvedDestPath ? path.dirname(task.resolvedDestPath) : null;\n if (dir && !result.includes(dir)) {\n result.push(dir);\n }\n return result;\n }, ensureDirs);\n }\n catch (error) {\n if (signal?.aborted) {\n this.log('warn', 'Operation aborted');\n return { batch, errorCount: failedCreateTaskCount };\n }\n if (!task.ignoreCreateTaskErrors) {\n this.log('error', `Failed to create download task(s) for item #${tt.id} in ${targetName}:`, error);\n failedCreateTaskCount++;\n }\n }\n }\n for (const dir of ensureDirs) {\n this.fsHelper.createDir(dir);\n }\n }\n if (failedCreateTaskCount > 0) {\n this.log('warn', `${failedCreateTaskCount} items could not be processed for downloading`);\n }\n return { batch, errorCount: failedCreateTaskCount };\n }\n\n async start(params: DownloaderStartParams) {\n try {\n await this.doStart(params);\n }\n finally {\n InnertubeLoader.reset();\n }\n }\n\n abstract doStart(params: DownloaderStartParams): Promise<void>;\n\n static async getInstance(\n target: string | ProductDownloaderBootstrapData | PostDownloaderBootstrapData,\n options?: DownloaderOptions\n ) {\n const bootstrap = typeof target === 'string' ? Bootstrap.getDownloaderBootstrapDataByURL(target) : target;\n if (!bootstrap) {\n throw Error('Could not determine downloader type from URL');\n }\n this.#validateOptions(options);\n\n const config = {\n ...bootstrap,\n ...getDownloaderInit(options)\n };\n const logger = options?.logger;\n const fsHelper = new FSHelper(config, logger);\n const db = () => DB.getInstance(fsHelper.getDBFilePath(), config.dryRun, logger);\n \n switch (config.type) {\n case 'product': {\n const ProductDownloader = (await import('./ProductDownloader.js')).default;\n return new ProductDownloader(config, db, logger);\n }\n case 'post': {\n const PostDownloader = (await import('./PostDownloader.js')).default;\n return new PostDownloader(config, db, logger);\n }\n }\n }\n\n static async getCampaign(\n params: GetCampaignParams,\n signal?: AbortSignal,\n options?: Logger | null | Pick<DownloaderOptions, 'cookie' | 'request' | 'logger'>\n ) {\n // Backwards compatibility - if 'params' is string type, then it is vanity\n let url: string;\n if (typeof params === 'string') {\n url = URLHelper.constructUserPostsURL({ vanity: params });\n }\n else if (params.userId || params.vanity) {\n url = URLHelper.constructUserPostsURL(params);\n }\n else {\n // Sole purpose of passing 'dummy' vanity is to create the PostDownloader instance\n url = URLHelper.constructUserPostsURL({ vanity: 'dummy' });\n }\n const downloader = await this.getInstance(\n url,\n options instanceof Logger ? { logger: options } : (options || undefined)\n );\n const PostDownloader = (await import('./PostDownloader.js')).default;\n if (downloader instanceof PostDownloader) {\n if (typeof params === 'object' && params.campaignId) {\n const { json } = await downloader.fetchCampaign(params.campaignId, signal);\n const parser = new PostParser(downloader.getFetcher(), options instanceof Logger ? options : options?.logger);\n return parser.parseCampaignAPIResponse(json);\n }\n return downloader.__getCampaign(signal);\n }\n throw Error('Type mismatch: PostDownloader expected');\n }\n\n static #validateOptions(options?: DownloaderOptions) {\n if (!options) {\n return true;\n }\n\n // Check FFmpeg path exists\n if (options.pathToFFmpeg) {\n if (!fs.existsSync(options.pathToFFmpeg)) {\n throw Error(`Path to FFmpeg executable \"${options.pathToFFmpeg}\" does not exist`);\n }\n else if (!fs.lstatSync(options.pathToFFmpeg).isFile()) {\n throw Error(`Path to FFmpeg executable \"${options.pathToFFmpeg}\" does not point to a file`);\n }\n }\n\n // Check Deno path exists and startable\n if (options.pathToDeno) {\n if (!fs.existsSync(options.pathToDeno)) {\n throw Error(`Path to Deno executable \"${options.pathToDeno}\" does not exist`);\n }\n else if (!fs.lstatSync(options.pathToDeno).isFile()) {\n throw Error(`Path to Deno executable \"${options.pathToDeno}\" does not point to a file`);\n }\n const di = isDenoInstalled(options.pathToDeno);\n if (!di.installed) {\n throw Error(`Could not start Deno executable \"${options.pathToDeno}\"`, { cause: di.error });\n }\n }\n\n // Check outDir is a directory\n if (options.outDir) {\n if (fs.existsSync(options.outDir) && !fs.lstatSync(options.outDir).isDirectory()) {\n throw Error(`\"${options.outDir}\" is not a directory`);\n }\n }\n\n // Check formats are valid\n const campaignDirNameFormat = options.dirNameFormat?.campaign;\n if (campaignDirNameFormat) {\n const validate = FilenameFormatHelper.validateCampaignDirNameFormat(campaignDirNameFormat);\n if (!validate.validateOK) {\n throw Error(`Campaign directory name format '${campaignDirNameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n const contentDirNameFormat = options.dirNameFormat?.content;\n if (contentDirNameFormat) {\n const validate = FilenameFormatHelper.validateContentDirNameFormat(contentDirNameFormat);\n if (!validate.validateOK) {\n throw Error(`Content directory name format '${contentDirNameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n const mediaFilenameFormat = options.filenameFormat?.media;\n if (mediaFilenameFormat) {\n const validate = FilenameFormatHelper.validateMediaFilenameFormat(mediaFilenameFormat);\n if (!validate.validateOK) {\n throw Error(`Media filename format '${mediaFilenameFormat}' is invalid (matched against ${validate.regex})`);\n }\n }\n\n return true;\n }\n\n protected async saveCampaignInfo(campaign: Campaign | null, signal?: AbortSignal) {\n const db = await this.db();\n if (!this.config.include.campaignInfo) {\n if (campaign) {\n db.saveCampaign(campaign, new Date());\n }\n return;\n }\n\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n let batch: DownloadTaskBatch | null = null;\n const abortHandler = () => {\n void (async () => {\n if (batch) {\n await batch.abort();\n }\n })();\n };\n if (signal) {\n signal.addEventListener('abort', abortHandler, { once: true });\n }\n\n if (!campaign) {\n this.log('warn', 'Skipped saving campaign info: target unavailable');\n return;\n }\n\n this.log('info', `Save campaign info #${campaign.id}`);\n this.emit('targetBegin', { target: campaign });\n this.emit('phaseBegin', { target: campaign, phase: 'saveInfo' });\n\n // Step 1: create campaign directories\n const campaignDirs = this.fsHelper.getCampaignDirs(campaign);\n this.log('debug', 'Campaign directories: ', campaignDirs);\n this.fsHelper.createDir(campaignDirs.root);\n this.fsHelper.createDir(campaignDirs.info);\n\n // Step 2: save summary and raw json\n const summary = generateCampaignSummary(campaign);\n const summaryFile = path.resolve(campaignDirs.info, 'info.txt');\n const saveSummaryResult = await this.fsHelper.writeTextFile(summaryFile, summary, this.config.fileExistsAction.info);\n this.logWriteTextFileResult(saveSummaryResult, campaign, 'campaign summary');\n\n // Campaign / creator raw data might not be complete. Fetch directly from API.\n // Strictly speaking, we should check for 'error' in results, but since it's not going to be fatal we'll just skip it.\n const { json: fetchedCampaignAPIData } = await this.fetchCampaign(campaign.id, signal);\n const { json: fetchedCreatorAPIData } = campaign.creator ? await this.fetchUser(campaign.creator.id, signal) : { json: null };\n\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n const campaignRawFile = path.resolve(campaignDirs.info, 'campaign-api.json');\n const saveCampaignRawResult = await this.fsHelper.writeTextFile(\n campaignRawFile, fetchedCampaignAPIData || campaign.raw, this.config.fileExistsAction.infoAPI);\n this.logWriteTextFileResult(saveCampaignRawResult, campaign, 'campaign API data');\n\n if (campaign.creator) {\n const creatorRawFile = path.resolve(campaignDirs.info, 'creator-api.json');\n const saveCreatorRawResult = await this.fsHelper.writeTextFile(\n creatorRawFile, fetchedCreatorAPIData || campaign.creator.raw, this.config.fileExistsAction.infoAPI);\n this.logWriteTextFileResult(saveCreatorRawResult, campaign.creator, 'creator API data');\n }\n\n this.emit('phaseEnd', { target: campaign, phase: 'saveInfo' });\n\n // Step 3: download campaign media items\n this.emit('phaseBegin', { target: campaign, phase: 'saveMedia' });\n const campaignMedia: Downloadable[] = [\n campaign.avatarImage,\n campaign.coverPhoto\n ];\n if (campaign.creator) {\n campaignMedia.push(\n campaign.creator.image,\n campaign.creator.thumbnail\n );\n }\n for (const reward of campaign.rewards) {\n if (reward.image) {\n campaignMedia.push(reward.image);\n }\n }\n batch = (await this.createDownloadTaskBatch(\n `Campaign #${campaign.id} (${campaign.name})`,\n signal,\n {\n target: campaignMedia,\n targetName: `campaign #${campaign.id} -> images`,\n src: campaign,\n dirs: {\n campaign: campaignDirs.root,\n main: campaignDirs.info,\n thumbnails: null\n },\n fileExistsAction: this.config.fileExistsAction.info\n }\n )).batch;\n if (this.checkAbortSignal(signal)) {\n return;\n }\n batch.prestart();\n this.emit('phaseBegin', { target: campaign, phase: 'batchDownload', batch });\n await batch.start();\n await batch.destroy();\n this.emit('phaseEnd', { target: campaign, phase: 'batchDownload' });\n this.emit('phaseEnd', { target: campaign, phase: 'saveMedia' });\n\n if (signal) {\n signal.removeEventListener('abort', abortHandler);\n }\n if (this.checkAbortSignal(signal)) {\n return;\n }\n\n // Step 4: save to DB\n db.saveCampaign(campaign, new Date());\n\n // Done\n this.log('info', 'Done saving campaign info');\n this.emit('targetEnd', { target: campaign, isSkipped: false });\n }\n\n protected log(level: LogLevel, ...msg: any[]) {\n commonLog(this.logger, level, this.name, ...msg);\n }\n\n getConfig(ro: false): DownloaderConfig<T>;\n getConfig(ro?: true): deepFreeze.DeepReadonly<DownloaderConfig<T>>;\n getConfig(ro = true) {\n return ro ? deepFreeze(this.config) : this.config;\n }\n\n protected checkAbortSignal(signal: AbortSignal | undefined) {\n if (signal && signal.aborted) {\n if (!this.#hasEmittedEndEventOnAbort) {\n this.emit('end', { aborted: true, message: 'Download aborted' });\n this.#hasEmittedEndEventOnAbort = true;\n }\n return true;\n }\n return false;\n }\n\n protected logWriteTextFileResult(result: WriteTextFileResult, target: {id: string}, targetName: string) {\n switch (result.status) {\n case 'completed':\n this.log('info', `Saved ${targetName} to \"${result.filePath}\"`);\n break;\n case 'skipped':\n this.log('warn', `Skipped saving ${targetName} #${target.id}: ${result.message}`);\n break;\n case 'error':\n this.log('error', `Error saving ${targetName} #${target.id} to \"${result.filePath}\":`, result.error);\n }\n }\n\n protected async commonFetchAPI(url: string, signal?: AbortSignal) {\n let json, requestAPIError: any;\n try {\n json = (await this.fetcher.get({ url, type: 'json', maxRetries: this.config.request.maxRetries, signal })).json;\n }\n catch (error) {\n if (signal?.aborted) {\n this.log('warn', 'API request aborted');\n }\n else {\n this.log('error', `Error requesting API URL \"${url}\": `, error);\n requestAPIError = error;\n }\n json = null;\n }\n return { json, error: requestAPIError };\n }\n\n protected fetchCampaign(campaignId: string, signal?: AbortSignal) {\n const url = URLHelper.constructCampaignAPIURL(campaignId);\n this.log('debug', `Fetch campaign data from API URL \"${url}\"`);\n return this.commonFetchAPI(url, signal);\n }\n\n protected fetchUser(userId: string, signal?: AbortSignal) {\n const url = URLHelper.constructUserAPIURL(userId);\n this.log('debug', `Fetch user data from API URL \"${url}\"`);\n return this.commonFetchAPI(url, signal);\n }\n\n protected async closeDB() {\n if (this.#dbPromise) {\n (await this.#dbPromise).close();\n this.#dbPromise = null;\n }\n }\n\n getFetcher() {\n return this.fetcher;\n }\n\n on<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n on(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.on(event, listener);\n }\n\n once<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n once(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.once(event, listener);\n }\n\n off<T extends DownloaderEvent>(event: T, listener: (args: DownloaderEventPayloadOf<T>) => void): this;\n off(event: string | symbol, listener: (...args: any[]) => void): this {\n return super.off(event, listener);\n }\n\n emit<T extends DownloaderEvent>(event: T, args: DownloaderEventPayloadOf<T>): boolean;\n emit(event: string | symbol, ...args: any[]): boolean {\n return super.emit(event, ...args);\n }\n}\n"]}
|
|
@@ -70,7 +70,7 @@ class PostDownloader extends Downloader {
|
|
|
70
70
|
signal
|
|
71
71
|
});
|
|
72
72
|
const { campaignId } = await postsFetcher.getInitialData(url);
|
|
73
|
-
const postsParser = new PostParser(this.logger);
|
|
73
|
+
const postsParser = new PostParser(this.fetcher, this.logger);
|
|
74
74
|
const res = await this.fetchCampaign(campaignId);
|
|
75
75
|
if (signal?.aborted) {
|
|
76
76
|
throw new Error('Aborted');
|
|
@@ -136,7 +136,7 @@ _PostDownloader_startPromise = new WeakMap(), _PostDownloader_context = new Weak
|
|
|
136
136
|
let campaignSaved = false;
|
|
137
137
|
let stopConditionMet = false;
|
|
138
138
|
const savedCollectionIds = [];
|
|
139
|
-
const postsParser = new PostParser(this.logger);
|
|
139
|
+
const postsParser = new PostParser(this.fetcher, this.logger);
|
|
140
140
|
while (postsFetcher.hasNext()) {
|
|
141
141
|
const { list, aborted, error } = await postsFetcher.next();
|
|
142
142
|
if (!list || aborted) {
|
|
@@ -182,7 +182,7 @@ _PostDownloader_startPromise = new WeakMap(), _PostDownloader_context = new Weak
|
|
|
182
182
|
const { json } = await this.commonFetchAPI(postURL, signal);
|
|
183
183
|
let refreshed = null;
|
|
184
184
|
if (json) {
|
|
185
|
-
refreshed = postsParser.parsePostsAPIResponse(json, postURL).items[0] || null;
|
|
185
|
+
refreshed = (await postsParser.parsePostsAPIResponse(json, postURL)).items[0] || null;
|
|
186
186
|
if (!refreshed) {
|
|
187
187
|
this.log('warn', `Refreshed post #${_post.id} but got empty value - going to use existing data`);
|
|
188
188
|
}
|
|
@@ -719,8 +719,8 @@ _PostDownloader_startPromise = new WeakMap(), _PostDownloader_context = new Weak
|
|
|
719
719
|
json = null;
|
|
720
720
|
}
|
|
721
721
|
if (json) {
|
|
722
|
-
const parser = new PostParser();
|
|
723
|
-
const parentPost = parser.parsePostsAPIResponse(json, apiURL).items[0];
|
|
722
|
+
const parser = new PostParser(this.fetcher);
|
|
723
|
+
const parentPost = (await parser.parsePostsAPIResponse(json, apiURL)).items[0];
|
|
724
724
|
if (!parentPost) {
|
|
725
725
|
this.log('error', `Error fetching linked attachment ${laStr} from parent post #${la.postId}: post data not found in response of "${apiURL}"`);
|
|
726
726
|
}
|