Skip to content

Commit a83b7f5

Browse files
committed
Added support for several new options via the Python API.
List of options: merge_output_format, noplaylist, cookiefile, cookiesfrombrowser, postprocessors: FFmpegSubtitlesConvertor
1 parent a2cfeea commit a83b7f5

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

youtube-dl-server.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
"YDL_EXTRACT_AUDIO_QUALITY", cast=str, default="192"
2222
),
2323
"YDL_RECODE_VIDEO_FORMAT": config("YDL_RECODE_VIDEO_FORMAT", default=None),
24+
"YDL_MERGE_OUTPUT_FORMAT": config("YDL_MERGE_OUTPUT_FORMAT", default=None),
2425
"YDL_OUTPUT_TEMPLATE": config(
2526
"YDL_OUTPUT_TEMPLATE",
2627
cast=str,
2728
default="/youtube-dl/%(title).200s [%(id)s].%(ext)s",
2829
),
30+
"YDL_NO_PLAYLIST": config("YDL_NO_PLAYLIST", cast=bool, default=True),
2931
"YDL_ARCHIVE_FILE": config("YDL_ARCHIVE_FILE", default=None),
32+
"YDL_COOKIES_FILE": config("YDL_COOKIES_FILE", default=None),
33+
"YDL_COOKIES_BROWSER": config("YDL_COOKIES_BROWSER", default=None),
3034
"YDL_UPDATE_TIME": config("YDL_UPDATE_TIME", cast=bool, default=True),
3135
"YDL_IGNORE_ERRORS": config("YDL_IGNORE_ERRORS", default=True),
3236
"YDL_RESTRICT_FILENAMES": config("YDL_RESTRICT_FILENAMES", cast=bool, default=False),
@@ -35,6 +39,7 @@
3539
"YDL_THUMBNAIL_FORMAT": config("YDL_THUMBNAIL_FORMAT", default=None),
3640
"YDL_WRITE_SUBTITLES": config("YDL_WRITE_SUBTITLES", cast=bool, default=False),
3741
"YDL_SUBTITLES_FORMAT": config("YDL_SUBTITLES_FORMAT", default=None),
42+
"YDL_CONVERT_SUBTITLES": config("YDL_CONVERT_SUBTITLES", default=None),
3843
"YDL_SUBTITLES_LANGS": config("YDL_SUBTITLES_LANGS", cast=str, default="all"),
3944
"YDL_EMBED_METADATA": config("YDL_EMBED_METADATA", cast=bool, default=False),
4045
}
@@ -148,22 +153,38 @@ def get_ydl_options(request_options):
148153
postprocessors.append(
149154
{
150155
"key": "FFmpegEmbedSubtitle",
151-
'already_have_subtitle': False,
156+
"already_have_subtitle": False,
157+
}
158+
)
159+
160+
if ydl_vars["YDL_CONVERT_SUBTITLES"]:
161+
postprocessors.append(
162+
{
163+
"key": "FFmpegSubtitlesConvertor",
164+
"format": ydl_vars["YDL_CONVERT_SUBTITLES"],
165+
"when": "post_process",
152166
}
153167
)
154168

155169
if ydl_vars["YDL_EMBED_METADATA"] == True:
156170
postprocessors.append(
157171
{
158172
"key": "FFmpegMetadata",
173+
"add_infojson": "if_exists",
174+
"add_metadata": True,
175+
"add_chapters": True,
159176
}
160177
)
161178

162179
return {
163180
"format": ydl_vars["YDL_FORMAT"],
181+
"merge_output_format": ydl_vars["YDL_MERGE_OUTPUT_FORMAT"],
164182
"postprocessors": postprocessors,
165183
"outtmpl": ydl_vars["YDL_OUTPUT_TEMPLATE"],
184+
"noplaylist": ydl_vars["YDL_NO_PLAYLIST"],
166185
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
186+
"cookiefile": ydl_vars["YDL_COOKIES_FILE"],
187+
"cookiesfrombrowser": ydl_vars["YDL_COOKIES_BROWSER"],
167188
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
168189
"ignoreerrors": ydl_vars["YDL_IGNORE_ERRORS"],
169190
"restrictfilenames": ydl_vars["YDL_RESTRICT_FILENAMES"],

0 commit comments

Comments
 (0)