mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-01 03:43:02 +00:00
[EmbedMetadata] Allow overwriting all default metadata
with `meta_default` key
This commit is contained in:
parent
24b0a72b30
commit
b11d210156
2 changed files with 11 additions and 12 deletions
|
@ -1433,7 +1433,7 @@ # MODIFYING METADATA
|
||||||
|
|
||||||
This option also has a few special uses:
|
This option also has a few special uses:
|
||||||
* You can download an additional URL based on the metadata of the currently downloaded video. To do this, set the field `additional_urls` to the URL that you want to download. Eg: `--parse-metadata "description:(?P<additional_urls>https?://www\.vimeo\.com/\d+)` will download the first vimeo video found in the description
|
* You can download an additional URL based on the metadata of the currently downloaded video. To do this, set the field `additional_urls` to the URL that you want to download. Eg: `--parse-metadata "description:(?P<additional_urls>https?://www\.vimeo\.com/\d+)` will download the first vimeo video found in the description
|
||||||
* You can use this to change the metadata that is embedded in the media file. To do this, set the value of the corresponding field with a `meta_` prefix. For example, any value you set to `meta_description` field will be added to the `description` field in the file. For example, you can use this to set a different "description" and "synopsis"
|
* You can use this to change the metadata that is embedded in the media file. To do this, set the value of the corresponding field with a `meta_` prefix. For example, any value you set to `meta_description` field will be added to the `description` field in the file. For example, you can use this to set a different "description" and "synopsis". Any value set to the `meta_` field will overwrite all default values.
|
||||||
|
|
||||||
For reference, these are the fields yt-dlp adds by default to the file metadata:
|
For reference, these are the fields yt-dlp adds by default to the file metadata:
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
from .common import AudioConversionError, PostProcessor
|
from .common import AudioConversionError, PostProcessor
|
||||||
|
|
||||||
from ..compat import compat_str, compat_numeric_types
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
dfxp2srt,
|
dfxp2srt,
|
||||||
encodeArgument,
|
encodeArgument,
|
||||||
|
@ -664,15 +664,14 @@ def ffmpeg_escape(text):
|
||||||
|
|
||||||
def _get_metadata_opts(self, info):
|
def _get_metadata_opts(self, info):
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
meta_prefix = 'meta_'
|
||||||
|
|
||||||
def add(meta_list, info_list=None):
|
def add(meta_list, info_list=None):
|
||||||
if not meta_list:
|
value = next((
|
||||||
return
|
str(info[key]) for key in [meta_prefix] + list(variadic(info_list or meta_list))
|
||||||
for info_f in variadic(info_list or meta_list):
|
if info.get(key) is not None), None)
|
||||||
if isinstance(info.get(info_f), (compat_str, compat_numeric_types)):
|
if value not in ('', None):
|
||||||
for meta_f in variadic(meta_list):
|
metadata.update({meta_f: value for meta_f in variadic(meta_list)})
|
||||||
metadata[meta_f] = info[info_f]
|
|
||||||
break
|
|
||||||
|
|
||||||
# See [1-4] for some info on media metadata/metadata supported
|
# See [1-4] for some info on media metadata/metadata supported
|
||||||
# by ffmpeg.
|
# by ffmpeg.
|
||||||
|
@ -695,9 +694,9 @@ def add(meta_list, info_list=None):
|
||||||
add('episode_id', ('episode', 'episode_id'))
|
add('episode_id', ('episode', 'episode_id'))
|
||||||
add('episode_sort', 'episode_number')
|
add('episode_sort', 'episode_number')
|
||||||
|
|
||||||
prefix = 'meta_'
|
for key, value in info.items():
|
||||||
for key in filter(lambda k: k.startswith(prefix), info.keys()):
|
if value is not None and key != meta_prefix and key.startswith(meta_prefix):
|
||||||
add(key[len(prefix):], key)
|
metadata[key[len(meta_prefix):]] = value
|
||||||
|
|
||||||
for name, value in metadata.items():
|
for name, value in metadata.items():
|
||||||
yield ('-metadata', f'{name}={value}')
|
yield ('-metadata', f'{name}={value}')
|
||||||
|
|
Loading…
Reference in a new issue