From f1129a54fd7c014e3aae7466c37660efe9ae260f Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 20 Feb 2024 08:57:02 +0530 Subject: [PATCH] Add compat-option --- README.md | 2 +- yt_dlp/options.py | 3 ++- yt_dlp/postprocessor/embedthumbnail.py | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c621e425a..ce02017e4 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ ### Differences in default behavior * Unavailable videos are also listed for YouTube playlists. Use `--compat-options no-youtube-unavailable-videos` to remove this * The upload dates extracted from YouTube are in UTC [when available](https://github.com/yt-dlp/yt-dlp/blob/89e4d86171c7b7c997c77d4714542e0383bf0db0/yt_dlp/extractor/youtube.py#L3898-L3900). Use `--compat-options no-youtube-prefer-utc-upload-date` to prefer the non-UTC upload date. * 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 +* Thumbnail embedding in `mp4`/`mp3` are done with `mutagen` if possible. Use `--compat-options no-embed-thumbnail-mutagen` to force the use of `ffmpeg`/`AtomicParsley` instead * Some internal metadata 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 separate 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 * `certifi` will be used for SSL root certificates, if installed. If you want to use system certificates (e.g. self-signed), use `--compat-options no-certifi` diff --git a/yt_dlp/options.py b/yt_dlp/options.py index ad4e2190c..9de301a56 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -468,11 +468,12 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs): 'allowed_values': { 'filename', 'filename-sanitization', 'format-sort', 'abort-on-error', 'format-spec', 'no-playlist-metafiles', 'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge', 'playlist-match-filter', - 'no-attach-info-json', 'embed-thumbnail-atomicparsley', 'no-external-downloader-progress', + 'no-attach-info-json', 'no-embed-thumbnail-mutagen', 'no-external-downloader-progress', 'embed-metadata', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs', 'no-certifi', 'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-youtube-prefer-utc-upload-date', 'prefer-legacy-http-handler', 'manifest-filesize-approx' }, 'aliases': { + 'embed-thumbnail-atomicparsley': ['no-embed-thumbnail-mutagen'], # compat 'youtube-dl': ['all', '-multistreams', '-playlist-match-filter', '-manifest-filesize-approx'], 'youtube-dlc': ['all', '-no-youtube-channel-redirect', '-no-live-chat', '-playlist-match-filter', '-manifest-filesize-approx'], '2021': ['2022', 'no-certifi', 'filename-sanitization', 'no-youtube-prefer-utc-upload-date'], diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py index 4abab40d3..8712c2e3f 100644 --- a/yt_dlp/postprocessor/embedthumbnail.py +++ b/yt_dlp/postprocessor/embedthumbnail.py @@ -88,10 +88,15 @@ def run(self, info): mtime = os.stat(encodeFilename(filename)).st_mtime + avoid_mutagen = any( + opt in self.get_param('compat_opts', []) + for opt in ('no-embed-thumbnail-mutagen', 'embed-thumbnail-atomicparsley')) success = True if info['ext'] == 'mp3': # Method 1: Use mutagen - if not mutagen: + if avoid_mutagen: + success = False + elif not mutagen: self.to_screen('mutagen not was found. Falling back to ffmpeg. Lyrics may be corrupted') success = False else: @@ -135,9 +140,8 @@ def run(self, info): self.run_ffmpeg(filename, temp_filename, options) elif info['ext'] in ['m4a', 'mp4', 'm4v', 'mov']: - prefer_atomicparsley = 'embed-thumbnail-atomicparsley' in self.get_param('compat_opts', []) # Method 1: Use mutagen - if not mutagen or prefer_atomicparsley: + if avoid_mutagen or not mutagen: success = False else: try: @@ -166,7 +170,7 @@ def run(self, info): self.to_screen('Neither mutagen nor AtomicParsley was found. Falling back to ffmpeg') success = False else: - if not prefer_atomicparsley: + if not avoid_mutagen: self.to_screen('mutagen was not found. Falling back to AtomicParsley') cmd = [encodeFilename(atomicparsley, True), encodeFilename(filename, True),