Skip to content

Commit

Permalink
Added support for several new options via the Python API.
Browse files Browse the repository at this point in the history
List of options: merge_output_format, noplaylist, cookiefile, cookiesfrombrowser, postprocessors: FFmpegSubtitlesConvertor
  • Loading branch information
qx6ghqkz committed May 30, 2024
1 parent a2cfeea commit a83b7f5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion youtube-dl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
"YDL_EXTRACT_AUDIO_QUALITY", cast=str, default="192"
),
"YDL_RECODE_VIDEO_FORMAT": config("YDL_RECODE_VIDEO_FORMAT", default=None),
"YDL_MERGE_OUTPUT_FORMAT": config("YDL_MERGE_OUTPUT_FORMAT", default=None),
"YDL_OUTPUT_TEMPLATE": config(
"YDL_OUTPUT_TEMPLATE",
cast=str,
default="/youtube-dl/%(title).200s [%(id)s].%(ext)s",
),
"YDL_NO_PLAYLIST": config("YDL_NO_PLAYLIST", cast=bool, default=True),
"YDL_ARCHIVE_FILE": config("YDL_ARCHIVE_FILE", default=None),
"YDL_COOKIES_FILE": config("YDL_COOKIES_FILE", default=None),
"YDL_COOKIES_BROWSER": config("YDL_COOKIES_BROWSER", default=None),
"YDL_UPDATE_TIME": config("YDL_UPDATE_TIME", cast=bool, default=True),
"YDL_IGNORE_ERRORS": config("YDL_IGNORE_ERRORS", default=True),
"YDL_RESTRICT_FILENAMES": config("YDL_RESTRICT_FILENAMES", cast=bool, default=False),
Expand All @@ -35,6 +39,7 @@
"YDL_THUMBNAIL_FORMAT": config("YDL_THUMBNAIL_FORMAT", default=None),
"YDL_WRITE_SUBTITLES": config("YDL_WRITE_SUBTITLES", cast=bool, default=False),
"YDL_SUBTITLES_FORMAT": config("YDL_SUBTITLES_FORMAT", default=None),
"YDL_CONVERT_SUBTITLES": config("YDL_CONVERT_SUBTITLES", default=None),
"YDL_SUBTITLES_LANGS": config("YDL_SUBTITLES_LANGS", cast=str, default="all"),
"YDL_EMBED_METADATA": config("YDL_EMBED_METADATA", cast=bool, default=False),
}
Expand Down Expand Up @@ -148,22 +153,38 @@ def get_ydl_options(request_options):
postprocessors.append(
{
"key": "FFmpegEmbedSubtitle",
'already_have_subtitle': False,
"already_have_subtitle": False,
}
)

if ydl_vars["YDL_CONVERT_SUBTITLES"]:
postprocessors.append(
{
"key": "FFmpegSubtitlesConvertor",
"format": ydl_vars["YDL_CONVERT_SUBTITLES"],
"when": "post_process",
}
)

if ydl_vars["YDL_EMBED_METADATA"] == True:
postprocessors.append(
{
"key": "FFmpegMetadata",
"add_infojson": "if_exists",
"add_metadata": True,
"add_chapters": True,
}
)

return {
"format": ydl_vars["YDL_FORMAT"],
"merge_output_format": ydl_vars["YDL_MERGE_OUTPUT_FORMAT"],
"postprocessors": postprocessors,
"outtmpl": ydl_vars["YDL_OUTPUT_TEMPLATE"],
"noplaylist": ydl_vars["YDL_NO_PLAYLIST"],
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
"cookiefile": ydl_vars["YDL_COOKIES_FILE"],
"cookiesfrombrowser": ydl_vars["YDL_COOKIES_BROWSER"],
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
"ignoreerrors": ydl_vars["YDL_IGNORE_ERRORS"],
"restrictfilenames": ydl_vars["YDL_RESTRICT_FILENAMES"],
Expand Down

0 comments on commit a83b7f5

Please sign in to comment.