From 265e0f7154e6cae93e33427ca8cd32170d1001e5 Mon Sep 17 00:00:00 2001 From: Lev Plyusnin Date: Wed, 3 Jan 2024 14:12:02 +0700 Subject: [PATCH] Rename new fields - Moved fix_deprecated_fields into _fill_common_fields --- yt_dlp/YoutubeDL.py | 23 +++++++++++------------ yt_dlp/extractor/common.py | 16 ++++++++-------- yt_dlp/postprocessor/ffmpeg.py | 8 ++++---- yt_dlp/postprocessor/mutagenmetadata.py | 8 ++++---- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 6d30d223e..fe63e249e 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -24,6 +24,7 @@ import unicodedata from .cache import Cache + from .compat import functools, urllib # isort: split from .compat import compat_os_name, compat_shlex_quote, urllib_req_to_req from .cookies import LenientSimpleCookie, load_cookies @@ -1735,7 +1736,6 @@ def __extract_info(self, url, ie, download, extra_info, process): '_type': 'compat_list', 'entries': ie_result, } - self.fix_deprecated_fields(ie_result) if extra_info.get('original_url'): ie_result.setdefault('original_url', extra_info['original_url']) self.add_default_extra_info(ie_result, ie, url) @@ -1745,17 +1745,6 @@ def __extract_info(self, url, ie, download, extra_info, process): else: return ie_result - def fix_deprecated_fields(self, ie_result): - deprecated_multivalue_fields = { - 'artist': 'artist_list', - 'composer': 'composer_list', - 'album_artist': 'album_artist_list', - 'genre': 'genre_list', - } - for deprecated_field, new_field in deprecated_multivalue_fields.items(): - if ie_result.get(deprecated_field): - ie_result[new_field] = re.split(r', ?', ie_result[deprecated_field]) - def add_default_extra_info(self, ie_result, ie, url): if url is not None: self.add_extra_info(ie_result, { @@ -2653,6 +2642,16 @@ def _fill_common_fields(self, info_dict, final=True): if final and info_dict.get('%s_number' % field) is not None and not info_dict.get(field): info_dict[field] = '%s %d' % (field.capitalize(), info_dict['%s_number' % field]) + deprecated_multivalue_fields = { + 'artist': 'artists', + 'composer': 'composers', + 'album_artist': 'album_artists', + 'genre': 'genres', + } + for deprecated_field, new_field in deprecated_multivalue_fields.items(): + if info_dict.get(deprecated_field): + info_dict[new_field] = re.split(r', ?', info_dict[deprecated_field]) + def _raise_pending_errors(self, info): err = info.pop('__pending_error', None) if err: diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index f11ae0e8c..20015769d 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -422,23 +422,23 @@ class InfoExtractor: track_number: Number of the track within an album or a disc, as an integer. track_id: Id of the track (useful in case of custom indexing, e.g. 6.iii), as a unicode string. - artist_list: List of artists of the track. - composer_list: List of composers of the piece - genre_list: List of genres of the track. + artists: List of artists of the track. + composers: List of composers of the piece + genres: List of genres of the track. album: Title of the album the track belongs to. album_type: Type of the album (e.g. "Demo", "Full-length", "Split", "Compilation", etc). - album_artist_list: List of all artists appeared on the album. + album_artists: List of all artists appeared on the album. E.g. ["Ash Borer", "Fell Voices"] or ["Various Artists"]. Useful for splits and compilations. disc_number: Number of the disc or other physical medium the track belongs to, as an integer. - composer: Deprecated; use "composer_list" instead. + composer: Deprecated; use "composers" instead. Composer(s) of the piece, comma-separated. - artist: Deprecated; use "artist_list" instead. + artist: Deprecated; use "artists" instead. Artist(s) of the track, comma-separated. - genre: Deprecated; use "genre_list" instead. + genre: Deprecated; use "genres" instead. Genre(s) of the track, comma-separated. - album_artist: Deprecated; use "album_artist_list" instead. + album_artist: Deprecated; use "album_artists" instead. All artists appeared on the album, comma-separated. The following fields should only be set for clips that should be cut from the original video: diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index f9ceb5eb4..c94c556ca 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -755,11 +755,11 @@ def add(meta_list, info_list=None): add(('description', 'synopsis'), 'description') add(('purl', 'comment'), 'webpage_url') add('track', 'track_number') - add('artist', ('artist_list', 'creator', 'uploader', 'uploader_id')) - add('composer', 'composer_list') - add('genre', 'genre_list') + add('artist', ('artists', 'creator', 'uploader', 'uploader_id')) + add('composer', 'composers') + add('genre', 'genres') add('album') - add('album_artist', 'album_artist_list') + add('album_artist', 'album_artists') add('disc', 'disc_number') add('show', 'series') add('season_number') diff --git a/yt_dlp/postprocessor/mutagenmetadata.py b/yt_dlp/postprocessor/mutagenmetadata.py index 25d7f016c..7a2925ed8 100644 --- a/yt_dlp/postprocessor/mutagenmetadata.py +++ b/yt_dlp/postprocessor/mutagenmetadata.py @@ -23,10 +23,10 @@ def run(self, information): self.report_warning('module mutagen was not found. Tags with multiple values (e.g. artist, album artist and genre) may be set incorrectly. Please install using `python -m pip install mutagen`') return ret tag_mapping = { - 'artist': 'artist_list', - 'albumartist': 'album_artist_list', - 'genre': 'genre_list', - 'composer': 'composer_list' + 'artist': 'artists', + 'albumartist': 'album_artists', + 'genre': 'genres', + 'composer': 'composers' } supported_formats = [EasyMP3, EasyMP4, OggVorbis, OggOpus, FLAC, Musepack] file = mutagen.File(information['filepath'], supported_formats)