Skip to content

Commit 0182110

Browse files
committed
feat(workers): allows videoWorker to use ytdlp command line arguments specified in the config
1 parent 7bffa02 commit 0182110

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

apps/workers/videoWorker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ export class VideoWorker {
6363
}
6464

6565
function prepareYtDlpArguments(url: string, assetPath: string) {
66-
// TODO allow custom commandline arguments?
6766
const ytDlpArguments = [url];
6867
if (serverConfig.crawler.maxVideoDownloadSize > 0) {
6968
ytDlpArguments.push(
7069
"-f",
7170
`best[filesize<${serverConfig.crawler.maxVideoDownloadSize}M]`,
7271
);
7372
}
73+
74+
ytDlpArguments.push(...serverConfig.crawler.ytDlpArguments);
7475
ytDlpArguments.push("-o", assetPath);
7576
ytDlpArguments.push("--no-playlist");
7677
return ytDlpArguments;

docs/docs/03-configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Either `OPENAI_API_KEY` or `OLLAMA_BASE_URL` need to be set for automatic taggin
8787
| CRAWLER_VIDEO_DOWNLOAD_MAX_SIZE | No | 50 | The maximum file size for the downloaded video. The quality will be chosen accordingly. Use -1 to disable the limit. |
8888
| CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC | No | 600 | How long to wait for the video download to finish |
8989
| CRAWLER_ENABLE_ADBLOCKER | No | true | Whether to enable an adblocker in the crawler or not. If you're facing troubles downloading the adblocking lists on worker startup, you can disable this. |
90+
| YTDLP_ARGS | No | [] | Include additional YTDLP arguments to be passed at crawl time: https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#general-options
9091

9192
## OCR Configs
9293

packages/shared/config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const allEnv = z.object({
4949
CRAWLER_VIDEO_DOWNLOAD_MAX_SIZE: z.coerce.number().default(50),
5050
CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC: z.coerce.number().default(10 * 60),
5151
CRAWLER_ENABLE_ADBLOCKER: stringBool("true"),
52+
YTDLP_ARGS: z
53+
.string()
54+
.default("")
55+
.transform((t) => t.split("%%").filter((a) => a)),
5256
MEILI_ADDR: z.string().optional(),
5357
MEILI_MASTER_KEY: z.string().default(""),
5458
LOG_LEVEL: z.string().default("debug"),
@@ -116,6 +120,7 @@ const serverConfigSchema = allEnv.transform((val) => {
116120
maxVideoDownloadSize: val.CRAWLER_VIDEO_DOWNLOAD_MAX_SIZE,
117121
downloadVideoTimeout: val.CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC,
118122
enableAdblocker: val.CRAWLER_ENABLE_ADBLOCKER,
123+
ytDlpArguments: val.YTDLP_ARGS,
119124
},
120125
ocr: {
121126
langs: val.OCR_LANGS,

0 commit comments

Comments
 (0)