patreon-dl 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +422 -0
  2. package/bin/patreon-dl.js +5 -0
  3. package/dist/cli/CLIOptionValidator.d.ts +9 -0
  4. package/dist/cli/CLIOptionValidator.d.ts.map +1 -0
  5. package/dist/cli/CLIOptionValidator.js +85 -0
  6. package/dist/cli/CLIOptionValidator.js.map +1 -0
  7. package/dist/cli/CLIOptions.d.ts +20 -0
  8. package/dist/cli/CLIOptions.d.ts.map +1 -0
  9. package/dist/cli/CLIOptions.js +75 -0
  10. package/dist/cli/CLIOptions.js.map +1 -0
  11. package/dist/cli/CommandLineParser.d.ts +11 -0
  12. package/dist/cli/CommandLineParser.d.ts.map +1 -0
  13. package/dist/cli/CommandLineParser.js +212 -0
  14. package/dist/cli/CommandLineParser.js.map +1 -0
  15. package/dist/cli/ConfigFileParser.d.ts +9 -0
  16. package/dist/cli/ConfigFileParser.d.ts.map +1 -0
  17. package/dist/cli/ConfigFileParser.js +163 -0
  18. package/dist/cli/ConfigFileParser.js.map +1 -0
  19. package/dist/cli/index.d.ts +7 -0
  20. package/dist/cli/index.d.ts.map +1 -0
  21. package/dist/cli/index.js +162 -0
  22. package/dist/cli/index.js.map +1 -0
  23. package/dist/downloaders/Bootstrap.d.ts +29 -0
  24. package/dist/downloaders/Bootstrap.d.ts.map +1 -0
  25. package/dist/downloaders/Bootstrap.js +51 -0
  26. package/dist/downloaders/Bootstrap.js.map +1 -0
  27. package/dist/downloaders/Downloader.d.ts +59 -0
  28. package/dist/downloaders/Downloader.d.ts.map +1 -0
  29. package/dist/downloaders/Downloader.js +357 -0
  30. package/dist/downloaders/Downloader.js.map +1 -0
  31. package/dist/downloaders/DownloaderEvent.d.ts +47 -0
  32. package/dist/downloaders/DownloaderEvent.d.ts.map +1 -0
  33. package/dist/downloaders/DownloaderEvent.js +6 -0
  34. package/dist/downloaders/DownloaderEvent.js.map +1 -0
  35. package/dist/downloaders/DownloaderOptions.d.ts +39 -0
  36. package/dist/downloaders/DownloaderOptions.d.ts.map +1 -0
  37. package/dist/downloaders/DownloaderOptions.js +69 -0
  38. package/dist/downloaders/DownloaderOptions.js.map +1 -0
  39. package/dist/downloaders/PostDownloader.d.ts +8 -0
  40. package/dist/downloaders/PostDownloader.d.ts.map +1 -0
  41. package/dist/downloaders/PostDownloader.js +428 -0
  42. package/dist/downloaders/PostDownloader.js.map +1 -0
  43. package/dist/downloaders/ProductDownloader.d.ts +8 -0
  44. package/dist/downloaders/ProductDownloader.d.ts.map +1 -0
  45. package/dist/downloaders/ProductDownloader.js +171 -0
  46. package/dist/downloaders/ProductDownloader.js.map +1 -0
  47. package/dist/downloaders/cache/StatusCache.d.ts +43 -0
  48. package/dist/downloaders/cache/StatusCache.d.ts.map +1 -0
  49. package/dist/downloaders/cache/StatusCache.js +206 -0
  50. package/dist/downloaders/cache/StatusCache.js.map +1 -0
  51. package/dist/downloaders/index.d.ts +7 -0
  52. package/dist/downloaders/index.d.ts.map +1 -0
  53. package/dist/downloaders/index.js +6 -0
  54. package/dist/downloaders/index.js.map +1 -0
  55. package/dist/downloaders/task/DownloadTask.d.ts +89 -0
  56. package/dist/downloaders/task/DownloadTask.d.ts.map +1 -0
  57. package/dist/downloaders/task/DownloadTask.js +240 -0
  58. package/dist/downloaders/task/DownloadTask.js.map +1 -0
  59. package/dist/downloaders/task/DownloadTaskBatch.d.ts +45 -0
  60. package/dist/downloaders/task/DownloadTaskBatch.d.ts.map +1 -0
  61. package/dist/downloaders/task/DownloadTaskBatch.js +195 -0
  62. package/dist/downloaders/task/DownloadTaskBatch.js.map +1 -0
  63. package/dist/downloaders/task/DownloadTaskBatchEvent.d.ts +32 -0
  64. package/dist/downloaders/task/DownloadTaskBatchEvent.d.ts.map +1 -0
  65. package/dist/downloaders/task/DownloadTaskBatchEvent.js +2 -0
  66. package/dist/downloaders/task/DownloadTaskBatchEvent.js.map +1 -0
  67. package/dist/downloaders/task/DownloadTaskFactory.d.ts +20 -0
  68. package/dist/downloaders/task/DownloadTaskFactory.d.ts.map +1 -0
  69. package/dist/downloaders/task/DownloadTaskFactory.js +177 -0
  70. package/dist/downloaders/task/DownloadTaskFactory.js.map +1 -0
  71. package/dist/downloaders/task/FFmpegDownloadTask.d.ts +27 -0
  72. package/dist/downloaders/task/FFmpegDownloadTask.d.ts.map +1 -0
  73. package/dist/downloaders/task/FFmpegDownloadTask.js +206 -0
  74. package/dist/downloaders/task/FFmpegDownloadTask.js.map +1 -0
  75. package/dist/downloaders/task/FetcherDownloadTask.d.ts +21 -0
  76. package/dist/downloaders/task/FetcherDownloadTask.d.ts.map +1 -0
  77. package/dist/downloaders/task/FetcherDownloadTask.js +213 -0
  78. package/dist/downloaders/task/FetcherDownloadTask.js.map +1 -0
  79. package/dist/downloaders/task/index.d.ts +4 -0
  80. package/dist/downloaders/task/index.d.ts.map +1 -0
  81. package/dist/downloaders/task/index.js +3 -0
  82. package/dist/downloaders/task/index.js.map +1 -0
  83. package/dist/downloaders/templates/CampaignInfo.d.ts +3 -0
  84. package/dist/downloaders/templates/CampaignInfo.d.ts.map +1 -0
  85. package/dist/downloaders/templates/CampaignInfo.js +58 -0
  86. package/dist/downloaders/templates/CampaignInfo.js.map +1 -0
  87. package/dist/downloaders/templates/PostInfo.d.ts +4 -0
  88. package/dist/downloaders/templates/PostInfo.d.ts.map +1 -0
  89. package/dist/downloaders/templates/PostInfo.js +45 -0
  90. package/dist/downloaders/templates/PostInfo.js.map +1 -0
  91. package/dist/downloaders/templates/ProductInfo.d.ts +3 -0
  92. package/dist/downloaders/templates/ProductInfo.d.ts.map +1 -0
  93. package/dist/downloaders/templates/ProductInfo.js +20 -0
  94. package/dist/downloaders/templates/ProductInfo.js.map +1 -0
  95. package/dist/entities/Attachment.d.ts +7 -0
  96. package/dist/entities/Attachment.d.ts.map +1 -0
  97. package/dist/entities/Attachment.js +2 -0
  98. package/dist/entities/Attachment.js.map +1 -0
  99. package/dist/entities/Campaign.d.ts +19 -0
  100. package/dist/entities/Campaign.d.ts.map +1 -0
  101. package/dist/entities/Campaign.js +2 -0
  102. package/dist/entities/Campaign.js.map +1 -0
  103. package/dist/entities/Downloadable.d.ts +6 -0
  104. package/dist/entities/Downloadable.d.ts.map +1 -0
  105. package/dist/entities/Downloadable.js +5 -0
  106. package/dist/entities/Downloadable.js.map +1 -0
  107. package/dist/entities/MediaItem.d.ts +95 -0
  108. package/dist/entities/MediaItem.d.ts.map +1 -0
  109. package/dist/entities/MediaItem.js +2 -0
  110. package/dist/entities/MediaItem.js.map +1 -0
  111. package/dist/entities/Post.d.ts +87 -0
  112. package/dist/entities/Post.d.ts.map +1 -0
  113. package/dist/entities/Post.js +2 -0
  114. package/dist/entities/Post.js.map +1 -0
  115. package/dist/entities/Product.d.ts +17 -0
  116. package/dist/entities/Product.d.ts.map +1 -0
  117. package/dist/entities/Product.js +2 -0
  118. package/dist/entities/Product.js.map +1 -0
  119. package/dist/entities/Reward.d.ts +14 -0
  120. package/dist/entities/Reward.d.ts.map +1 -0
  121. package/dist/entities/Reward.js +2 -0
  122. package/dist/entities/Reward.js.map +1 -0
  123. package/dist/entities/User.d.ts +15 -0
  124. package/dist/entities/User.d.ts.map +1 -0
  125. package/dist/entities/User.js +2 -0
  126. package/dist/entities/User.js.map +1 -0
  127. package/dist/entities/index.d.ts +9 -0
  128. package/dist/entities/index.d.ts.map +1 -0
  129. package/dist/entities/index.js +6 -0
  130. package/dist/entities/index.js.map +1 -0
  131. package/dist/index.d.ts +8 -0
  132. package/dist/index.d.ts.map +1 -0
  133. package/dist/index.js +8 -0
  134. package/dist/index.js.map +1 -0
  135. package/dist/parsers/PageParser.d.ts +6 -0
  136. package/dist/parsers/PageParser.d.ts.map +1 -0
  137. package/dist/parsers/PageParser.js +23 -0
  138. package/dist/parsers/PageParser.js.map +1 -0
  139. package/dist/parsers/Parser.d.ts +43 -0
  140. package/dist/parsers/Parser.d.ts.map +1 -0
  141. package/dist/parsers/Parser.js +439 -0
  142. package/dist/parsers/Parser.js.map +1 -0
  143. package/dist/parsers/PostParser.d.ts +7 -0
  144. package/dist/parsers/PostParser.d.ts.map +1 -0
  145. package/dist/parsers/PostParser.js +259 -0
  146. package/dist/parsers/PostParser.js.map +1 -0
  147. package/dist/parsers/ProductParser.d.ts +7 -0
  148. package/dist/parsers/ProductParser.d.ts.map +1 -0
  149. package/dist/parsers/ProductParser.js +70 -0
  150. package/dist/parsers/ProductParser.js.map +1 -0
  151. package/dist/utils/AttachmentFilenameResolver.d.ts +9 -0
  152. package/dist/utils/AttachmentFilenameResolver.d.ts.map +1 -0
  153. package/dist/utils/AttachmentFilenameResolver.js +73 -0
  154. package/dist/utils/AttachmentFilenameResolver.js.map +1 -0
  155. package/dist/utils/FSHelper.d.ts +57 -0
  156. package/dist/utils/FSHelper.d.ts.map +1 -0
  157. package/dist/utils/FSHelper.js +214 -0
  158. package/dist/utils/FSHelper.js.map +1 -0
  159. package/dist/utils/Fetcher.d.ts +45 -0
  160. package/dist/utils/Fetcher.d.ts.map +1 -0
  161. package/dist/utils/Fetcher.js +192 -0
  162. package/dist/utils/Fetcher.js.map +1 -0
  163. package/dist/utils/FetcherProgressMonitor.d.ts +18 -0
  164. package/dist/utils/FetcherProgressMonitor.d.ts.map +1 -0
  165. package/dist/utils/FetcherProgressMonitor.js +56 -0
  166. package/dist/utils/FetcherProgressMonitor.js.map +1 -0
  167. package/dist/utils/FilenameFormatHelper.d.ts +44 -0
  168. package/dist/utils/FilenameFormatHelper.d.ts.map +1 -0
  169. package/dist/utils/FilenameFormatHelper.js +98 -0
  170. package/dist/utils/FilenameFormatHelper.js.map +1 -0
  171. package/dist/utils/FllenameResolver.d.ts +20 -0
  172. package/dist/utils/FllenameResolver.d.ts.map +1 -0
  173. package/dist/utils/FllenameResolver.js +55 -0
  174. package/dist/utils/FllenameResolver.js.map +1 -0
  175. package/dist/utils/Formatter.d.ts +21 -0
  176. package/dist/utils/Formatter.d.ts.map +1 -0
  177. package/dist/utils/Formatter.js +112 -0
  178. package/dist/utils/Formatter.js.map +1 -0
  179. package/dist/utils/MediaFilenameResolver.d.ts +9 -0
  180. package/dist/utils/MediaFilenameResolver.d.ts.map +1 -0
  181. package/dist/utils/MediaFilenameResolver.js +90 -0
  182. package/dist/utils/MediaFilenameResolver.js.map +1 -0
  183. package/dist/utils/Misc.d.ts +14 -0
  184. package/dist/utils/Misc.d.ts.map +1 -0
  185. package/dist/utils/Misc.js +4 -0
  186. package/dist/utils/Misc.js.map +1 -0
  187. package/dist/utils/ObjectHelper.d.ts +4 -0
  188. package/dist/utils/ObjectHelper.d.ts.map +1 -0
  189. package/dist/utils/ObjectHelper.js +30 -0
  190. package/dist/utils/ObjectHelper.js.map +1 -0
  191. package/dist/utils/PackageInfo.d.ts +10 -0
  192. package/dist/utils/PackageInfo.d.ts.map +1 -0
  193. package/dist/utils/PackageInfo.js +33 -0
  194. package/dist/utils/PackageInfo.js.map +1 -0
  195. package/dist/utils/URLHelper.d.ts +40 -0
  196. package/dist/utils/URLHelper.d.ts.map +1 -0
  197. package/dist/utils/URLHelper.js +192 -0
  198. package/dist/utils/URLHelper.js.map +1 -0
  199. package/dist/utils/index.d.ts +2 -0
  200. package/dist/utils/index.d.ts.map +1 -0
  201. package/dist/utils/index.js +2 -0
  202. package/dist/utils/index.js.map +1 -0
  203. package/dist/utils/logging/ChainLogger.d.ts +11 -0
  204. package/dist/utils/logging/ChainLogger.d.ts.map +1 -0
  205. package/dist/utils/logging/ChainLogger.js +50 -0
  206. package/dist/utils/logging/ChainLogger.js.map +1 -0
  207. package/dist/utils/logging/ConsoleLogger.d.ts +31 -0
  208. package/dist/utils/logging/ConsoleLogger.d.ts.map +1 -0
  209. package/dist/utils/logging/ConsoleLogger.js +126 -0
  210. package/dist/utils/logging/ConsoleLogger.js.map +1 -0
  211. package/dist/utils/logging/FileLogger.d.ts +26 -0
  212. package/dist/utils/logging/FileLogger.d.ts.map +1 -0
  213. package/dist/utils/logging/FileLogger.js +147 -0
  214. package/dist/utils/logging/FileLogger.js.map +1 -0
  215. package/dist/utils/logging/Logger.d.ts +12 -0
  216. package/dist/utils/logging/Logger.d.ts.map +1 -0
  217. package/dist/utils/logging/Logger.js +15 -0
  218. package/dist/utils/logging/Logger.js.map +1 -0
  219. package/dist/utils/logging/index.d.ts +7 -0
  220. package/dist/utils/logging/index.d.ts.map +1 -0
  221. package/dist/utils/logging/index.js +7 -0
  222. package/dist/utils/logging/index.js.map +1 -0
  223. package/package.json +78 -0
@@ -0,0 +1,75 @@
1
+ import { pickDefined } from '../utils/Misc.js';
2
+ import CLIOptionValidator from './CLIOptionValidator.js';
3
+ import CommandLineParser from './CommandLineParser.js';
4
+ import ConfigFileParser from './ConfigFileParser.js';
5
+ export function getCLIOptions() {
6
+ const commandLineOptions = CommandLineParser.parse();
7
+ let configFileOptions = null;
8
+ if (commandLineOptions.configFile?.value) {
9
+ configFileOptions = ConfigFileParser.parse(commandLineOptions.configFile.value);
10
+ }
11
+ const options = {
12
+ targetURL: CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURL, configFileOptions?.targetURL), 'No target URL specified'),
13
+ cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),
14
+ useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),
15
+ pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),
16
+ outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),
17
+ dirNameFormat: {
18
+ campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),
19
+ content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))
20
+ },
21
+ filenameFormat: {
22
+ media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))
23
+ },
24
+ include: {
25
+ lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),
26
+ campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),
27
+ contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),
28
+ previewMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),
29
+ contentMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),
30
+ allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants))
31
+ },
32
+ request: {
33
+ maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),
34
+ maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),
35
+ minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime))
36
+ },
37
+ fileExistsAction: {
38
+ content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.content, configFileOptions?.fileExistsAction?.content), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),
39
+ info: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.info, configFileOptions?.fileExistsAction?.info), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),
40
+ infoAPI: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.infoAPI, configFileOptions?.fileExistsAction?.infoAPI), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer')
41
+ },
42
+ noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,
43
+ consoleLogger: {
44
+ enabled: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.enabled, configFileOptions?.consoleLogger?.enabled)),
45
+ logLevel: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.logLevel, configFileOptions?.consoleLogger?.logLevel), 'info', 'debug', 'warn', 'error'),
46
+ include: {
47
+ dateTime: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.dateTime, configFileOptions?.consoleLogger?.include?.dateTime)),
48
+ level: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.level, configFileOptions?.consoleLogger?.include?.level)),
49
+ originator: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.originator, configFileOptions?.consoleLogger?.include?.originator)),
50
+ errorStack: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.errorStack, configFileOptions?.consoleLogger?.include?.errorStack))
51
+ },
52
+ dateTimeFormat: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.dateTimeFormat, configFileOptions?.consoleLogger?.dateTimeFormat)),
53
+ color: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.color, configFileOptions?.consoleLogger?.color))
54
+ }
55
+ };
56
+ if (configFileOptions?.fileLoggers) {
57
+ options.fileLoggers = configFileOptions.fileLoggers.map((logger) => ({
58
+ enabled: CLIOptionValidator.validateBoolean(logger.enabled),
59
+ logDir: CLIOptionValidator.validateString(logger.logDir),
60
+ logFilename: CLIOptionValidator.validateString(logger.logFilename),
61
+ fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),
62
+ logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),
63
+ include: {
64
+ dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),
65
+ level: CLIOptionValidator.validateBoolean(logger.include?.level),
66
+ originator: CLIOptionValidator.validateBoolean(logger.include?.originator),
67
+ errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)
68
+ },
69
+ dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),
70
+ color: CLIOptionValidator.validateBoolean(logger.color)
71
+ }));
72
+ }
73
+ return options;
74
+ }
75
+ //# sourceMappingURL=CLIOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CLIOptions.js","sourceRoot":"","sources":["../../src/cli/CLIOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAmBrD,MAAM,UAAU,aAAa;IAC3B,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAErD,IAAI,iBAAiB,GAAwD,IAAI,CAAC;IAClF,IAAI,kBAAkB,CAAC,UAAU,EAAE,KAAK,EAAE;QACxC,iBAAiB,GAAG,gBAAgB,CAAC,KAAK,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;KACjF;IAED,MAAM,OAAO,GAAe;QAC1B,SAAS,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,yBAAyB,CAAC;QAClJ,MAAM,EAAE,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;QAC5G,cAAc,EAAE,kBAAkB,CAAC,eAAe,CAAC,WAAW,CAAC,kBAAkB,CAAC,cAAc,EAAE,iBAAiB,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C,OAAO,EAAE,UAAU,CAAC;gBAC1E,UAAU,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;aAC3E;YACD,cAAc,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC;YACxE,KAAK,EAAE,kBAAkB,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC;SACxD,CAAC,CAAC,CAAC;KACL;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { DownloaderOptions } from '../downloaders/DownloaderOptions.js';\nimport { pickDefined } from '../utils/Misc.js';\nimport { ConsoleLoggerOptions } from '../utils/logging/ConsoleLogger.js';\nimport { FileLoggerOptions } from '../utils/logging/FileLogger.js';\nimport CLIOptionValidator from './CLIOptionValidator.js';\nimport CommandLineParser from './CommandLineParser.js';\nimport ConfigFileParser from './ConfigFileParser.js';\n\nexport interface CLIOptions extends Omit<DownloaderOptions, 'logger'> {\n targetURL: string;\n noPrompt: boolean;\n consoleLogger: ConsoleLoggerOptions;\n fileLoggers?: FileLoggerOptions[];\n}\n\nexport type CLIOptionParserEntry = ({\n src: 'cli'\n} | {\n src: 'cfg',\n section: string\n}) & {\n key: string;\n value?: string;\n}\n\nexport function getCLIOptions(): CLIOptions {\n const commandLineOptions = CommandLineParser.parse();\n\n let configFileOptions: ReturnType<typeof ConfigFileParser['parse']> | null = null;\n if (commandLineOptions.configFile?.value) {\n configFileOptions = ConfigFileParser.parse(commandLineOptions.configFile.value);\n }\n\n const options: CLIOptions = {\n targetURL: CLIOptionValidator.validateRequired(pickDefined(commandLineOptions.targetURL, configFileOptions?.targetURL), 'No target URL specified'),\n cookie: CLIOptionValidator.validateString(pickDefined(commandLineOptions.cookie, configFileOptions?.cookie)),\n useStatusCache: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.useStatusCache, configFileOptions?.useStatusCache)),\n pathToFFmpeg: CLIOptionValidator.validateString(pickDefined(commandLineOptions.pathToFFmpeg, configFileOptions?.pathToFFmpeg)),\n outDir: CLIOptionValidator.validateString(pickDefined(commandLineOptions.outDir, configFileOptions?.outDir)),\n dirNameFormat: {\n campaign: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.campaign, configFileOptions?.dirNameFormat?.campaign)),\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.dirNameFormat?.content, configFileOptions?.dirNameFormat?.content))\n },\n filenameFormat: {\n media: CLIOptionValidator.validateString(pickDefined(commandLineOptions.filenameFormat?.media, configFileOptions?.filenameFormat?.media))\n },\n include: {\n lockedContent: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.lockedContent, configFileOptions?.include?.lockedContent)),\n campaignInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.campaignInfo, configFileOptions?.include?.campaignInfo)),\n contentInfo: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentInfo, configFileOptions?.include?.contentInfo)),\n previewMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.previewMedia, configFileOptions?.include?.previewMedia)),\n contentMedia: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.contentMedia, configFileOptions?.include?.contentMedia)),\n allMediaVariants: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.include?.allMediaVariants, configFileOptions?.include?.allMediaVariants))\n },\n request: {\n maxRetries: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxRetries, configFileOptions?.request?.maxRetries)),\n maxConcurrent: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.maxConcurrent, configFileOptions?.request?.maxConcurrent)),\n minTime: CLIOptionValidator.validateNumber(pickDefined(commandLineOptions?.request?.minTime, configFileOptions?.request?.minTime))\n },\n fileExistsAction: {\n content: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.content, configFileOptions?.fileExistsAction?.content), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n info: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.info, configFileOptions?.fileExistsAction?.info), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer'),\n infoAPI: CLIOptionValidator.validateString(pickDefined(commandLineOptions.fileExistsAction?.infoAPI, configFileOptions?.fileExistsAction?.infoAPI), 'overwrite', 'skip', 'saveAsCopy', 'saveAsCopyIfNewer')\n },\n noPrompt: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.noPrompt, configFileOptions?.noPrompt)) || false,\n consoleLogger: {\n enabled: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.enabled, configFileOptions?.consoleLogger?.enabled)),\n logLevel: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.logLevel, configFileOptions?.consoleLogger?.logLevel), 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.dateTime, configFileOptions?.consoleLogger?.include?.dateTime)),\n level: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.level, configFileOptions?.consoleLogger?.include?.level)),\n originator: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.originator, configFileOptions?.consoleLogger?.include?.originator)),\n errorStack: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.include?.errorStack, configFileOptions?.consoleLogger?.include?.errorStack))\n },\n dateTimeFormat: CLIOptionValidator.validateString(pickDefined(commandLineOptions.consoleLogger?.dateTimeFormat, configFileOptions?.consoleLogger?.dateTimeFormat)),\n color: CLIOptionValidator.validateBoolean(pickDefined(commandLineOptions.consoleLogger?.color, configFileOptions?.consoleLogger?.color))\n }\n };\n\n if (configFileOptions?.fileLoggers) {\n options.fileLoggers = configFileOptions.fileLoggers.map((logger): FileLoggerOptions => ({\n enabled: CLIOptionValidator.validateBoolean(logger.enabled),\n logDir: CLIOptionValidator.validateString(logger.logDir),\n logFilename: CLIOptionValidator.validateString(logger.logFilename),\n fileExistsAction: CLIOptionValidator.validateString(logger.fileExistsAction, 'append', 'overwrite'),\n logLevel: CLIOptionValidator.validateString(logger.logLevel, 'info', 'debug', 'warn', 'error'),\n include: {\n dateTime: CLIOptionValidator.validateBoolean(logger.include?.dateTime),\n level: CLIOptionValidator.validateBoolean(logger.include?.level),\n originator: CLIOptionValidator.validateBoolean(logger.include?.originator),\n errorStack: CLIOptionValidator.validateBoolean(logger.include?.errorStack)\n },\n dateTimeFormat: CLIOptionValidator.validateString(logger.dateTimeFormat),\n color: CLIOptionValidator.validateBoolean(logger.color)\n }));\n }\n\n return options;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';
2
+ import { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';
3
+ export interface CommandLineParseResult extends RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry> {
4
+ configFile?: CLIOptionParserEntry;
5
+ }
6
+ export default class CommandLineParser {
7
+ #private;
8
+ static parse(): CommandLineParseResult;
9
+ static showUsage(): boolean;
10
+ }
11
+ //# sourceMappingURL=CommandLineParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandLineParser.d.ts","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAC7G,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC;AAqED,MAAM,CAAC,OAAO,OAAO,iBAAiB;;IAEpC,MAAM,CAAC,KAAK,IAAI,sBAAsB;IA6FtC,MAAM,CAAC,SAAS;CAiDjB"}
@@ -0,0 +1,212 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _a, _CommandLineParser_parseArgs;
7
+ import commandLineArgs from 'command-line-args';
8
+ import commandLineUsage from 'command-line-usage';
9
+ import { EOL } from 'os';
10
+ import { getPackageInfo } from '../utils/PackageInfo.js';
11
+ const COMMAND_LINE_ARGS = {
12
+ help: 'help',
13
+ configFile: 'config-file',
14
+ targetURL: 'target-url',
15
+ cookie: 'cookie',
16
+ ffmpeg: 'ffmpeg',
17
+ outDir: 'out-dir',
18
+ logLevel: 'log-level',
19
+ noPrompt: 'no-prompt'
20
+ };
21
+ const OPT_DEFS = [
22
+ {
23
+ name: COMMAND_LINE_ARGS.help,
24
+ description: 'Display this usage guide',
25
+ alias: 'h',
26
+ type: Boolean
27
+ },
28
+ {
29
+ name: COMMAND_LINE_ARGS.configFile,
30
+ description: 'Load configuration file for setting full options',
31
+ alias: 'C',
32
+ type: String,
33
+ typeLabel: '<file>'
34
+ },
35
+ {
36
+ name: COMMAND_LINE_ARGS.targetURL,
37
+ description: 'URL of content to download',
38
+ type: String,
39
+ defaultOption: true
40
+ },
41
+ {
42
+ name: COMMAND_LINE_ARGS.cookie,
43
+ description: 'Cookie for accessing patron-only content',
44
+ alias: 'c',
45
+ type: String,
46
+ typeLabel: '<string>'
47
+ },
48
+ {
49
+ name: COMMAND_LINE_ARGS.ffmpeg,
50
+ description: 'Path to FFmpeg executable',
51
+ alias: 'f',
52
+ type: String,
53
+ typeLabel: '<string>'
54
+ },
55
+ {
56
+ name: COMMAND_LINE_ARGS.outDir,
57
+ description: 'Path to directory where content is saved',
58
+ alias: 'o',
59
+ type: String,
60
+ typeLabel: '<dir>'
61
+ },
62
+ {
63
+ name: COMMAND_LINE_ARGS.logLevel,
64
+ description: 'Log level of the console logger: \'info\', \'debug\', \'warn\' or \'error\'; set to \'none\' to disable the logger.',
65
+ alias: 'l',
66
+ type: String,
67
+ typeLabel: '<level>'
68
+ },
69
+ {
70
+ name: COMMAND_LINE_ARGS.noPrompt,
71
+ description: 'Do not prompt for confirmation to proceed',
72
+ alias: 'y',
73
+ type: Boolean
74
+ }
75
+ ];
76
+ export default class CommandLineParser {
77
+ static parse() {
78
+ const opts = __classPrivateFieldGet(this, _a, "m", _CommandLineParser_parseArgs).call(this);
79
+ const argv = process.argv;
80
+ const __getOptNameUsed = (key) => {
81
+ const name = `--${key}`;
82
+ if (argv.includes(name)) {
83
+ return name;
84
+ }
85
+ const alias = OPT_DEFS.find((def) => def.name === key)?.alias;
86
+ if (alias) {
87
+ return `-${alias}`;
88
+ }
89
+ return name;
90
+ };
91
+ const __getValue = (key) => {
92
+ let value = opts[key];
93
+ if (key === COMMAND_LINE_ARGS.noPrompt && value !== undefined) {
94
+ value = '1';
95
+ }
96
+ else if (value === null) {
97
+ throw Error(`Command-line option requires a value for '--${key}'`);
98
+ }
99
+ if (value && typeof value === 'string') {
100
+ return {
101
+ src: 'cli',
102
+ key: __getOptNameUsed(key),
103
+ value: value.trim()
104
+ };
105
+ }
106
+ return undefined;
107
+ };
108
+ // Handle --log-level: none
109
+ let consoleLoggerLevel = __getValue(COMMAND_LINE_ARGS.logLevel);
110
+ let consoleLoggerEnabled;
111
+ if (consoleLoggerLevel?.value === 'none') {
112
+ consoleLoggerEnabled = {
113
+ src: 'cli',
114
+ key: '',
115
+ value: '0'
116
+ };
117
+ consoleLoggerLevel = undefined;
118
+ }
119
+ return {
120
+ configFile: __getValue(COMMAND_LINE_ARGS.configFile),
121
+ targetURL: __getValue(COMMAND_LINE_ARGS.targetURL),
122
+ cookie: __getValue(COMMAND_LINE_ARGS.cookie),
123
+ useStatusCache: undefined,
124
+ pathToFFmpeg: __getValue(COMMAND_LINE_ARGS.ffmpeg),
125
+ outDir: __getValue(COMMAND_LINE_ARGS.outDir),
126
+ dirNameFormat: {
127
+ campaign: undefined,
128
+ content: undefined
129
+ },
130
+ filenameFormat: {
131
+ media: undefined
132
+ },
133
+ include: {
134
+ campaignInfo: undefined,
135
+ contentInfo: undefined,
136
+ previewMedia: undefined,
137
+ contentMedia: undefined,
138
+ allMediaVariants: undefined
139
+ },
140
+ request: {
141
+ maxRetries: undefined,
142
+ maxConcurrent: undefined,
143
+ minTime: undefined
144
+ },
145
+ fileExistsAction: {
146
+ content: undefined,
147
+ info: undefined,
148
+ infoAPI: undefined
149
+ },
150
+ noPrompt: __getValue(COMMAND_LINE_ARGS.noPrompt),
151
+ consoleLogger: {
152
+ enabled: consoleLoggerEnabled,
153
+ logLevel: consoleLoggerLevel,
154
+ include: {
155
+ dateTime: undefined,
156
+ level: undefined,
157
+ originator: undefined,
158
+ errorStack: undefined
159
+ },
160
+ dateTimeFormat: undefined,
161
+ color: undefined
162
+ }
163
+ };
164
+ }
165
+ static showUsage() {
166
+ let opts;
167
+ try {
168
+ opts = __classPrivateFieldGet(this, _a, "m", _CommandLineParser_parseArgs).call(this);
169
+ }
170
+ catch (error) {
171
+ return false;
172
+ }
173
+ if (opts.help) {
174
+ const content = [
175
+ 'Command-line options override corresponding options in configuration file loaded through \'-C\'.',
176
+ EOL,
177
+ 'Project home: {underline https://github.com/patrickkfkan/patreon-dl}'
178
+ ];
179
+ const sections = [
180
+ {
181
+ header: 'Usage',
182
+ content: 'patreon-dl [OPTION]... URL'
183
+ },
184
+ {
185
+ header: 'Options',
186
+ optionList: OPT_DEFS,
187
+ hide: 'target-url'
188
+ },
189
+ {
190
+ content: content.join(EOL)
191
+ }
192
+ ];
193
+ const banner = getPackageInfo().banner;
194
+ if (banner) {
195
+ sections.unshift({ header: banner, raw: true });
196
+ }
197
+ const usage = commandLineUsage(sections);
198
+ console.log(usage);
199
+ return true;
200
+ }
201
+ return false;
202
+ }
203
+ }
204
+ _a = CommandLineParser, _CommandLineParser_parseArgs = function _CommandLineParser_parseArgs() {
205
+ const opts = commandLineArgs(OPT_DEFS, { stopAtFirstUnknown: true });
206
+ if (opts['_unknown']) {
207
+ const unknownOpt = Object.keys(opts['_unknown'])[0];
208
+ throw Error(`Unknown command-line option '${unknownOpt}'`);
209
+ }
210
+ return opts;
211
+ };
212
+ //# sourceMappingURL=CommandLineParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandLineParser.js","sourceRoot":"","sources":["../../src/cli/CommandLineParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMzD,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,YAAY;IACvB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;CACb,CAAC;AAEX,MAAM,QAAQ,GAAG;IACf;QACE,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,WAAW,EAAE,0BAA0B;QACvC,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,OAAO;KACd;IACD;QACE,IAAI,EAAE,iBAAiB,CAAC,UAAU;QAClC,WAAW,EAAE,kDAAkD;QAC/D,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;KACpB;IACD;QACE,IAAI,EAAE,iBAAiB,CAAC,SAAS;QACjC,WAAW,EAAE,4BAA4B;QACzC,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,IAAI;KACpB;IACD;QACE,IAA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,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE,QAAQ;oBACpB,IAAI,EAAE,YAAY;iBACnB;gBACD;oBACE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;iBAC3B;aACF,CAAC;YACF,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC,MAAM,CAAC;YACvC,IAAI,MAAM,EAAE;gBACV,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;aACjD;YACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAEnB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAUF;;IAPG,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;QACpB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC,gCAAgC,UAAU,GAAG,CAAC,CAAC;KAC5D;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import commandLineArgs from 'command-line-args';\nimport commandLineUsage from 'command-line-usage';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { EOL } from 'os';\nimport { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';\nimport { getPackageInfo } from '../utils/PackageInfo.js';\n\nexport interface CommandLineParseResult extends RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry> {\n configFile?: CLIOptionParserEntry;\n}\n\nconst COMMAND_LINE_ARGS = {\n help: 'help',\n configFile: 'config-file',\n targetURL: 'target-url',\n cookie: 'cookie',\n ffmpeg: 'ffmpeg',\n outDir: 'out-dir',\n logLevel: 'log-level',\n noPrompt: 'no-prompt'\n} as const;\n\nconst OPT_DEFS = [\n {\n name: COMMAND_LINE_ARGS.help,\n description: 'Display this usage guide',\n alias: 'h',\n type: Boolean\n },\n {\n name: COMMAND_LINE_ARGS.configFile,\n description: 'Load configuration file for setting full options',\n alias: 'C',\n type: String,\n typeLabel: '<file>'\n },\n {\n name: COMMAND_LINE_ARGS.targetURL,\n description: 'URL of content to download',\n type: String,\n defaultOption: true\n },\n {\n name: COMMAND_LINE_ARGS.cookie,\n description: 'Cookie for accessing patron-only content',\n alias: 'c',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.ffmpeg,\n description: 'Path to FFmpeg executable',\n alias: 'f',\n type: String,\n typeLabel: '<string>'\n },\n {\n name: COMMAND_LINE_ARGS.outDir,\n description: 'Path to directory where content is saved',\n alias: 'o',\n type: String,\n typeLabel: '<dir>'\n },\n {\n name: COMMAND_LINE_ARGS.logLevel,\n description: 'Log level of the console logger: \\'info\\', \\'debug\\', \\'warn\\' or \\'error\\'; set to \\'none\\' to disable the logger.',\n alias: 'l',\n type: String,\n typeLabel: '<level>'\n },\n {\n name: COMMAND_LINE_ARGS.noPrompt,\n description: 'Do not prompt for confirmation to proceed',\n alias: 'y',\n type: Boolean\n }\n];\n\nexport default class CommandLineParser {\n\n static parse(): CommandLineParseResult {\n const opts = this.#parseArgs();\n const argv = process.argv;\n\n const __getOptNameUsed = (key: string) => {\n const name = `--${key}`;\n if (argv.includes(name)) {\n return name;\n }\n const alias = OPT_DEFS.find((def) => def.name === key)?.alias;\n if (alias) {\n return `-${alias}`;\n }\n return name;\n };\n\n const __getValue = (key: typeof COMMAND_LINE_ARGS[keyof typeof COMMAND_LINE_ARGS]): CLIOptionParserEntry | undefined => {\n let value = opts[key];\n if (key === COMMAND_LINE_ARGS.noPrompt && value !== undefined) {\n value = '1';\n }\n else if (value === null) {\n throw Error(`Command-line option requires a value for '--${key}'`);\n }\n if (value && typeof value === 'string') {\n return {\n src: 'cli',\n key: __getOptNameUsed(key),\n value: value.trim()\n };\n }\n return undefined;\n };\n\n // Handle --log-level: none\n let consoleLoggerLevel = __getValue(COMMAND_LINE_ARGS.logLevel);\n let consoleLoggerEnabled: CLIOptionParserEntry | undefined;\n if (consoleLoggerLevel?.value === 'none') {\n consoleLoggerEnabled = {\n src: 'cli',\n key: '',\n value: '0'\n };\n consoleLoggerLevel = undefined;\n }\n\n return {\n configFile: __getValue(COMMAND_LINE_ARGS.configFile),\n targetURL: __getValue(COMMAND_LINE_ARGS.targetURL),\n cookie: __getValue(COMMAND_LINE_ARGS.cookie),\n useStatusCache: undefined,\n pathToFFmpeg: __getValue(COMMAND_LINE_ARGS.ffmpeg),\n outDir: __getValue(COMMAND_LINE_ARGS.outDir),\n dirNameFormat: {\n campaign: undefined,\n content: undefined\n },\n filenameFormat: {\n media: undefined\n },\n include: {\n campaignInfo: undefined,\n contentInfo: undefined,\n previewMedia: undefined,\n contentMedia: undefined,\n allMediaVariants: undefined\n },\n request: {\n maxRetries: undefined,\n maxConcurrent: undefined,\n minTime: undefined\n },\n fileExistsAction: {\n content: undefined,\n info: undefined,\n infoAPI: undefined\n },\n noPrompt: __getValue(COMMAND_LINE_ARGS.noPrompt),\n consoleLogger: {\n enabled: consoleLoggerEnabled,\n logLevel: consoleLoggerLevel,\n include: {\n dateTime: undefined,\n level: undefined,\n originator: undefined,\n errorStack: undefined\n },\n dateTimeFormat: undefined,\n color: undefined\n }\n };\n }\n\n static showUsage() {\n let opts;\n try {\n opts = this.#parseArgs();\n }\n catch (error) {\n return false;\n }\n if (opts.help) {\n const content = [\n 'Command-line options override corresponding options in configuration file loaded through \\'-C\\'.',\n EOL,\n 'Project home: {underline https://github.com/patrickkfkan/patreon-dl}'\n ];\n const sections: commandLineUsage.Section[] = [\n {\n header: 'Usage',\n content: 'patreon-dl [OPTION]... URL'\n },\n {\n header: 'Options',\n optionList: OPT_DEFS,\n hide: 'target-url'\n },\n {\n content: content.join(EOL)\n }\n ];\n const banner = getPackageInfo().banner;\n if (banner) {\n sections.unshift({ header: banner, raw: true });\n }\n const usage = commandLineUsage(sections);\n console.log(usage);\n\n return true;\n }\n\n return false;\n }\n\n static #parseArgs() {\n const opts = commandLineArgs(OPT_DEFS, { stopAtFirstUnknown: true });\n if (opts['_unknown']) {\n const unknownOpt = Object.keys(opts['_unknown'])[0];\n throw Error(`Unknown command-line option '${unknownOpt}'`);\n }\n return opts;\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';
2
+ import { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';
3
+ type ConfigFileParseResult = RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry>;
4
+ export default class ConfigFileParser {
5
+ #private;
6
+ static parse(file: string): ConfigFileParseResult;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=ConfigFileParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigFileParser.d.ts","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA+DjE,KAAK,qBAAqB,GAAG,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAE7F,MAAM,CAAC,OAAO,OAAO,gBAAgB;;IAEnC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB;CAsGlD"}
@@ -0,0 +1,163 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _a, _ConfigFileParser_getValueFromConfigParser, _ConfigFileParser_parseFileLoggerOptions;
7
+ import ConfigParser from 'configparser';
8
+ const CONFIG_FILE_PROPS = {
9
+ targetURL: 'downloader:target.url',
10
+ cookie: 'downloader:cookie',
11
+ useStatusCache: 'downloader:use.status.cache',
12
+ noPrompt: 'downloader:no.prompt',
13
+ pathToFFmpeg: 'downloader:path.to.ffmpeg',
14
+ outDir: 'output:out.dir',
15
+ dirNameFormat: {
16
+ campaign: 'output:campaign.dir.name.format',
17
+ content: 'output:content.dir.name.format'
18
+ },
19
+ filenameFormat: {
20
+ media: 'output:media.filename.format'
21
+ },
22
+ fileExistsAction: {
23
+ content: 'output:content.file.exists.action',
24
+ info: 'output:info.file.exists.action',
25
+ infoAPI: 'output:info.api.file.exists.action'
26
+ },
27
+ include: {
28
+ lockedContent: 'include:locked.content',
29
+ campaignInfo: 'include:campaign.info',
30
+ contentInfo: 'include:content.info',
31
+ previewMedia: 'include:preview.media',
32
+ contentMedia: 'include:content.media',
33
+ allMediaVariants: 'include:all.media.variants'
34
+ },
35
+ request: {
36
+ maxRetries: 'request:max.retries',
37
+ maxConcurrent: 'request:max.concurrent',
38
+ minTime: 'request:min.time'
39
+ },
40
+ consoleLogger: {
41
+ enabled: 'logger.console:enabled',
42
+ logLevel: 'logger.console:log.level',
43
+ include: {
44
+ dateTime: 'logger.console:include.date.time',
45
+ level: 'logger.console:include.level',
46
+ originator: 'logger.console:include.originator',
47
+ errorStack: 'logger.console:include.error.stack'
48
+ },
49
+ dateTimeFormat: 'logger.console:date.time.format',
50
+ color: 'logger.console:color'
51
+ },
52
+ fileLogger: {
53
+ enabled: ':enabled',
54
+ logDir: ':log.dir',
55
+ logFilename: ':log.filename',
56
+ fileExistsAction: ':file.exists.action',
57
+ logLevel: ':log.level',
58
+ include: {
59
+ dateTime: ':include.date.time',
60
+ level: ':include.level',
61
+ originator: ':include.originator',
62
+ errorStack: ':include.error.stack'
63
+ },
64
+ dateTimeFormat: ':date.time.format',
65
+ color: ':color'
66
+ }
67
+ };
68
+ export default class ConfigFileParser {
69
+ static parse(file) {
70
+ const parser = new ConfigParser();
71
+ parser.read(file);
72
+ const __getValue = (prop) => {
73
+ return __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_getValueFromConfigParser).call(this, parser, prop);
74
+ };
75
+ return {
76
+ targetURL: __getValue(CONFIG_FILE_PROPS.targetURL),
77
+ cookie: __getValue(CONFIG_FILE_PROPS.cookie),
78
+ useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),
79
+ pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),
80
+ outDir: __getValue(CONFIG_FILE_PROPS.outDir),
81
+ dirNameFormat: {
82
+ campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),
83
+ content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)
84
+ },
85
+ filenameFormat: {
86
+ media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)
87
+ },
88
+ include: {
89
+ lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),
90
+ campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),
91
+ contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),
92
+ previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),
93
+ contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),
94
+ allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants)
95
+ },
96
+ request: {
97
+ maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),
98
+ maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),
99
+ minTime: __getValue(CONFIG_FILE_PROPS.request.minTime)
100
+ },
101
+ fileExistsAction: {
102
+ content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),
103
+ info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),
104
+ infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)
105
+ },
106
+ noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),
107
+ consoleLogger: {
108
+ enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),
109
+ logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),
110
+ include: {
111
+ dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),
112
+ level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),
113
+ originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),
114
+ errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)
115
+ },
116
+ dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),
117
+ color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)
118
+ },
119
+ fileLoggers: __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_parseFileLoggerOptions).call(this, parser)
120
+ };
121
+ }
122
+ }
123
+ _a = ConfigFileParser, _ConfigFileParser_getValueFromConfigParser = function _ConfigFileParser_getValueFromConfigParser(parser, prop) {
124
+ const [section, key] = prop.split(':');
125
+ let value = parser.get(section, key)?.trim();
126
+ if (value && value.startsWith('"') && value.endsWith('"')) {
127
+ value = value.substring(1, value.length - 1);
128
+ }
129
+ if (value) {
130
+ return {
131
+ src: 'cfg',
132
+ section,
133
+ key,
134
+ value
135
+ };
136
+ }
137
+ return undefined;
138
+ }, _ConfigFileParser_parseFileLoggerOptions = function _ConfigFileParser_parseFileLoggerOptions(parser) {
139
+ const __getValue = (section, prop) => {
140
+ return __classPrivateFieldGet(this, _a, "m", _ConfigFileParser_getValueFromConfigParser).call(this, parser, `${section}${prop}`);
141
+ };
142
+ const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));
143
+ const loggers = sections.reduce((result, section) => {
144
+ result.push({
145
+ enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),
146
+ logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),
147
+ logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),
148
+ fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),
149
+ logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),
150
+ include: {
151
+ dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),
152
+ level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),
153
+ originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),
154
+ errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)
155
+ },
156
+ dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),
157
+ color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)
158
+ });
159
+ return result;
160
+ }, []);
161
+ return loggers.length > 0 ? loggers : undefined;
162
+ };
163
+ //# sourceMappingURL=ConfigFileParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigFileParser.js","sourceRoot":"","sources":["../../src/cli/ConfigFileParser.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAIxC,MAAM,iBAAiB,GAAG;IACxB,SAAS,EAAE,uBAAuB;IAClC,MAAM,EAAE,mBAAmB;IAC3B,cAAc,EAAE,6BAA6B;IAC7C,QAAQ,EAAE,sBAAsB;IAChC,YAAY,EAAE,2BAA2B;IACzC,MAAM,EAAE,gBAAgB;IACxB,aAAa,EAAE;QACb,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,gCAAgC;KAC1C;IACD,cAAc,EAAE;QACd,KAAK,EAAE,8BAA8B;KACtC;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,mCAAmC;QAC5C,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,oCAAoC;KAC9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AAiB,CAAC,UAAU,CAAC,QAAQ,CAAC;YACpE,OAAO,EAAE;gBACP,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC5E,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtE,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;gBAChF,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;aACjF;YACD,cAAc,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,cAAc,CAAC;YAChF,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC;SAC/D,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC","sourcesContent":["import ConfigParser from 'configparser';\nimport { CLIOptionParserEntry, CLIOptions } from './CLIOptions.js';\nimport { DeepPartial, RecursivePropsTo } from '../utils/Misc.js';\n\nconst CONFIG_FILE_PROPS = {\n targetURL: 'downloader:target.url',\n cookie: 'downloader:cookie',\n useStatusCache: 'downloader:use.status.cache',\n noPrompt: 'downloader:no.prompt',\n pathToFFmpeg: 'downloader:path.to.ffmpeg',\n outDir: 'output:out.dir',\n dirNameFormat: {\n campaign: 'output:campaign.dir.name.format',\n content: 'output:content.dir.name.format'\n },\n filenameFormat: {\n media: 'output:media.filename.format'\n },\n fileExistsAction: {\n content: 'output:content.file.exists.action',\n info: 'output:info.file.exists.action',\n infoAPI: 'output:info.api.file.exists.action'\n },\n include: {\n lockedContent: 'include:locked.content',\n campaignInfo: 'include:campaign.info',\n contentInfo: 'include:content.info',\n previewMedia: 'include:preview.media',\n contentMedia: 'include:content.media',\n allMediaVariants: 'include:all.media.variants'\n },\n request: {\n maxRetries: 'request:max.retries',\n maxConcurrent: 'request:max.concurrent',\n minTime: 'request:min.time'\n },\n consoleLogger: {\n enabled: 'logger.console:enabled',\n logLevel: 'logger.console:log.level',\n include: {\n dateTime: 'logger.console:include.date.time',\n level: 'logger.console:include.level',\n originator: 'logger.console:include.originator',\n errorStack: 'logger.console:include.error.stack'\n },\n dateTimeFormat: 'logger.console:date.time.format',\n color: 'logger.console:color'\n },\n fileLogger: {\n enabled: ':enabled',\n logDir: ':log.dir',\n logFilename: ':log.filename',\n fileExistsAction: ':file.exists.action',\n logLevel: ':log.level',\n include: {\n dateTime: ':include.date.time',\n level: ':include.level',\n originator: ':include.originator',\n errorStack: ':include.error.stack'\n },\n dateTimeFormat: ':date.time.format',\n color: ':color'\n }\n};\n\ntype ConfigFileParseResult = RecursivePropsTo<DeepPartial<CLIOptions>, CLIOptionParserEntry>;\n\nexport default class ConfigFileParser {\n\n static parse(file: string): ConfigFileParseResult {\n const parser = new ConfigParser();\n\n parser.read(file);\n\n const __getValue = (prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, prop);\n };\n\n return {\n targetURL: __getValue(CONFIG_FILE_PROPS.targetURL),\n cookie: __getValue(CONFIG_FILE_PROPS.cookie),\n useStatusCache: __getValue(CONFIG_FILE_PROPS.useStatusCache),\n pathToFFmpeg: __getValue(CONFIG_FILE_PROPS.pathToFFmpeg),\n outDir: __getValue(CONFIG_FILE_PROPS.outDir),\n dirNameFormat: {\n campaign: __getValue(CONFIG_FILE_PROPS.dirNameFormat.campaign),\n content: __getValue(CONFIG_FILE_PROPS.dirNameFormat.content)\n },\n filenameFormat: {\n media: __getValue(CONFIG_FILE_PROPS.filenameFormat.media)\n },\n include: {\n lockedContent: __getValue(CONFIG_FILE_PROPS.include.lockedContent),\n campaignInfo: __getValue(CONFIG_FILE_PROPS.include.campaignInfo),\n contentInfo: __getValue(CONFIG_FILE_PROPS.include.contentInfo),\n previewMedia: __getValue(CONFIG_FILE_PROPS.include.previewMedia),\n contentMedia: __getValue(CONFIG_FILE_PROPS.include.contentMedia),\n allMediaVariants: __getValue(CONFIG_FILE_PROPS.include.allMediaVariants)\n },\n request: {\n maxRetries: __getValue(CONFIG_FILE_PROPS.request.maxRetries),\n maxConcurrent: __getValue(CONFIG_FILE_PROPS.request.maxConcurrent),\n minTime: __getValue(CONFIG_FILE_PROPS.request.minTime)\n },\n fileExistsAction: {\n content: __getValue(CONFIG_FILE_PROPS.fileExistsAction.content),\n info: __getValue(CONFIG_FILE_PROPS.fileExistsAction.info),\n infoAPI: __getValue(CONFIG_FILE_PROPS.fileExistsAction.infoAPI)\n },\n noPrompt: __getValue(CONFIG_FILE_PROPS.noPrompt),\n consoleLogger: {\n enabled: __getValue(CONFIG_FILE_PROPS.consoleLogger.enabled),\n logLevel: __getValue(CONFIG_FILE_PROPS.consoleLogger.logLevel),\n include: {\n dateTime: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.dateTime),\n level: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.level),\n originator: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.originator),\n errorStack: __getValue(CONFIG_FILE_PROPS.consoleLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(CONFIG_FILE_PROPS.consoleLogger.dateTimeFormat),\n color: __getValue(CONFIG_FILE_PROPS.consoleLogger.color)\n },\n fileLoggers: this.#parseFileLoggerOptions(parser)\n };\n }\n\n static #getValueFromConfigParser(parser: ConfigParser, prop: string): CLIOptionParserEntry | undefined {\n const [ section, key ] = prop.split(':');\n let value = parser.get(section, key)?.trim();\n if (value && value.startsWith('\"') && value.endsWith('\"')) {\n value = value.substring(1, value.length - 1);\n }\n if (value) {\n return {\n src: 'cfg',\n section,\n key,\n value\n };\n }\n return undefined;\n }\n\n static #parseFileLoggerOptions(parser: ConfigParser) {\n const __getValue = (section: string, prop: string): CLIOptionParserEntry | undefined => {\n return this.#getValueFromConfigParser(parser, `${section}${prop}`);\n };\n\n const sections = parser.sections().filter((section) => section.startsWith('logger.file.'));\n\n const loggers = sections.reduce<NonNullable<ConfigFileParseResult['fileLoggers']>>((result, section) => {\n result.push({\n enabled: __getValue(section, CONFIG_FILE_PROPS.fileLogger.enabled),\n logDir: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logDir),\n logFilename: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logFilename),\n fileExistsAction: __getValue(section, CONFIG_FILE_PROPS.fileLogger.fileExistsAction),\n logLevel: __getValue(section, CONFIG_FILE_PROPS.fileLogger.logLevel),\n include: {\n dateTime: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.dateTime),\n level: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.level),\n originator: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.originator),\n errorStack: __getValue(section, CONFIG_FILE_PROPS.fileLogger.include.errorStack)\n },\n dateTimeFormat: __getValue(section, CONFIG_FILE_PROPS.fileLogger.dateTimeFormat),\n color: __getValue(section, CONFIG_FILE_PROPS.fileLogger.color)\n });\n return result;\n }, []);\n\n return loggers.length > 0 ? loggers : undefined;\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export default class PatreonDownloaderCLI {
2
+ #private;
3
+ constructor();
4
+ start(): Promise<void>;
5
+ exit(code?: number): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,OAAO,oBAAoB;;;IAUjC,KAAK;IAoJL,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;CAMzB"}