Rename new fields

- Moved fix_deprecated_fields into _fill_common_fields
This commit is contained in:
Lev Plyusnin 2024-01-03 14:12:02 +07:00
parent ac52bf0952
commit 265e0f7154
No known key found for this signature in database
GPG Key ID: 21C6C2C9C0A4460D
4 changed files with 27 additions and 28 deletions

View File

@ -24,6 +24,7 @@ import traceback
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 @@ class YoutubeDL:
'_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 @@ class YoutubeDL:
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 @@ class YoutubeDL:
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:

View File

@ -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:

View File

@ -755,11 +755,11 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
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')

View File

@ -23,10 +23,10 @@ class MutagenMetadataPP(PostProcessor):
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)