mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 17:08:32 +00:00
Merge 1a449af19e
into 73bf102116
This commit is contained in:
commit
ca2a584dc3
@ -28,6 +28,7 @@
|
||||
prepend_extension,
|
||||
replace_extension,
|
||||
shell_quote,
|
||||
strftime_or_none,
|
||||
traverse_obj,
|
||||
variadic,
|
||||
write_json_file,
|
||||
@ -736,12 +737,12 @@ def _get_metadata_opts(self, info):
|
||||
meta_prefix = 'meta'
|
||||
metadata = collections.defaultdict(dict)
|
||||
|
||||
def add(meta_list, info_list=None):
|
||||
def add(meta_list, info_list=None, convert=str):
|
||||
value = next((
|
||||
info[key] for key in [f'{meta_prefix}_', *variadic(info_list or meta_list)]
|
||||
if info.get(key) is not None), None)
|
||||
if value not in ('', None):
|
||||
value = ', '.join(map(str, variadic(value)))
|
||||
value = ', '.join(map(convert, variadic(value)))
|
||||
value = value.replace('\0', '') # nul character cannot be passed in command line
|
||||
metadata['common'].update(dict.fromkeys(variadic(meta_list), value))
|
||||
|
||||
@ -751,7 +752,7 @@ def add(meta_list, info_list=None):
|
||||
# https://kodi.wiki/view/Video_file_tagging
|
||||
|
||||
add('title', ('track', 'title'))
|
||||
add('date', 'upload_date')
|
||||
add('date', ('release_date', 'upload_date'), convert=strftime_or_none(date_format='%Y-%m-%d'))
|
||||
add(('description', 'synopsis'), 'description')
|
||||
add(('purl', 'comment'), 'webpage_url')
|
||||
add('track', 'track_number')
|
||||
|
@ -2047,6 +2047,7 @@ def url_or_none(url):
|
||||
return url if re.match(r'(?:(?:https?|rt(?:m(?:pt?[es]?|fp)|sp[su]?)|mms|ftps?|wss?):)?//', url) else None
|
||||
|
||||
|
||||
@partial_application
|
||||
def strftime_or_none(timestamp, date_format='%Y%m%d', default=None):
|
||||
datetime_object = None
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user