mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-16 03:26:46 +01:00
[cleanup] Use format_field where applicable
This commit is contained in:
parent
0bfc53d05c
commit
e0ddbd02bd
26 changed files with 59 additions and 52 deletions
|
|
@ -4975,13 +4975,10 @@ def to_high_limit_path(path):
|
|||
|
||||
|
||||
def format_field(obj, field=None, template='%s', ignore=(None, ''), default='', func=None):
|
||||
if field is None:
|
||||
val = obj if obj is not None else default
|
||||
else:
|
||||
val = obj.get(field, default)
|
||||
if func and val not in ignore:
|
||||
val = func(val)
|
||||
return template % val if val not in ignore else default
|
||||
val = traverse_obj(obj, *variadic(field))
|
||||
if val in ignore:
|
||||
return default
|
||||
return template % (func(val) if func else val)
|
||||
|
||||
|
||||
def clean_podcast_url(url):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue