mirror of
https://gitlab.com/dstftw/youtube-dl.git
synced 2020-11-16 09:42:26 +00:00
[postprocessor/ffmpeg] Simplify metadata preparation and add track related metafields (Closes #9357)
This commit is contained in:
parent
6f27bf1c74
commit
4bd143a3a0
|
@ -389,23 +389,30 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
class FFmpegMetadataPP(FFmpegPostProcessor):
|
class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
metadata = {}
|
metadata = {}
|
||||||
if info.get('title') is not None:
|
|
||||||
metadata['title'] = info['title']
|
def add(meta_list, info_list=None):
|
||||||
if info.get('upload_date') is not None:
|
if not info_list:
|
||||||
metadata['date'] = info['upload_date']
|
info_list = meta_list
|
||||||
if info.get('artist') is not None:
|
if not isinstance(meta_list, (list, tuple)):
|
||||||
metadata['artist'] = info['artist']
|
meta_list = (meta_list,)
|
||||||
elif info.get('uploader') is not None:
|
if not isinstance(info_list, (list, tuple)):
|
||||||
metadata['artist'] = info['uploader']
|
info_list = (info_list,)
|
||||||
elif info.get('uploader_id') is not None:
|
for info_f in info_list:
|
||||||
metadata['artist'] = info['uploader_id']
|
if info.get(info_f) is not None:
|
||||||
if info.get('description') is not None:
|
for meta_f in meta_list:
|
||||||
metadata['description'] = info['description']
|
metadata[meta_f] = info[info_f]
|
||||||
metadata['comment'] = info['description']
|
break
|
||||||
if info.get('webpage_url') is not None:
|
|
||||||
metadata['purl'] = info['webpage_url']
|
add('title', ('track', 'title'))
|
||||||
if info.get('album') is not None:
|
add('date', 'upload_date')
|
||||||
metadata['album'] = info['album']
|
add(('description', 'comment'), 'description')
|
||||||
|
add('purl', 'webpage_url')
|
||||||
|
add('track', 'track_number')
|
||||||
|
add('artist', ('artist', 'creator', 'uploader', 'uploader_id'))
|
||||||
|
add('genre')
|
||||||
|
add('album')
|
||||||
|
add('album_artist')
|
||||||
|
add('disc', 'disc_number')
|
||||||
|
|
||||||
if not metadata:
|
if not metadata:
|
||||||
self._downloader.to_screen('[ffmpeg] There isn\'t any metadata to add')
|
self._downloader.to_screen('[ffmpeg] There isn\'t any metadata to add')
|
||||||
|
|
Loading…
Reference in a new issue