From b51d2ae3cae121de084460f1260d5d644a566338 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 5 Aug 2021 23:30:53 +0530 Subject: [PATCH] Add compat-option `no-keep-subs` Closes #630 --- README.md | 1 + yt_dlp/YoutubeDL.py | 2 +- yt_dlp/__init__.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a308aa196..2c4bb8f35 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ ### Differences in default behavior * If `ffmpeg` is used as the downloader, the downloading and merging of formats happen in a single step when possible. Use `--compat-options no-direct-merge` to revert this * Thumbnail embedding in `mp4` is done with mutagen if possible. Use `--compat-options embed-thumbnail-atomicparsley` to force the use of AtomicParsley instead * Some private fields such as filenames are removed by default from the infojson. Use `--no-clean-infojson` or `--compat-options no-clean-infojson` to revert this +* When `--embed-subs` and `--write-subs` are used together, the subtitles are written to disk and also embedded in the media file. You can use just `--embed-subs` to embed the subs and automatically delete the seperate file. See [#630 (comment)](https://github.com/yt-dlp/yt-dlp/issues/630#issuecomment-893659460) for more info. `--compat-options no-keep-subs` can be used to revert this. For ease of use, a few more compat options are available: * `--compat-options all`: Use all compat options diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 19fc5bdb6..978f43054 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -404,7 +404,7 @@ class YoutubeDL(object): compat_opts: Compatibility options. See "Differences in default behavior". The following options do not work when used through the API: filename, abort-on-error, multistreams, no-live-chat, - no-clean-infojson, no-playlist-metafiles. + no-clean-infojson, no-playlist-metafiles, no-keep-subs. Refer __init__.py for their implementation The following parameters are not used by YoutubeDL itself, they are used by diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index fb0f46a4a..532d004c3 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -280,7 +280,7 @@ def parse_compat_opts(): 'filename', 'format-sort', 'abort-on-error', 'format-spec', 'no-playlist-metafiles', 'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge', 'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-attach-info-json', - 'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', + 'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs', ] compat_opts = parse_compat_opts() @@ -458,13 +458,13 @@ def report_conflict(arg1, arg2): if opts.addmetadata: postprocessors.append({'key': 'FFmpegMetadata'}) if opts.embedsubtitles: - already_have_subtitle = opts.writesubtitles + already_have_subtitle = opts.writesubtitles and 'no-keep-subs' not in compat_opts postprocessors.append({ 'key': 'FFmpegEmbedSubtitle', # already_have_subtitle = True prevents the file from being deleted after embedding 'already_have_subtitle': already_have_subtitle }) - if not already_have_subtitle: + if not opts.writeautomaticsub and 'no-keep-subs' not in compat_opts: opts.writesubtitles = True # --all-sub automatically sets --write-sub if --write-auto-sub is not given # this was the old behaviour if only --all-sub was given.