diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-21 13:27:40 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-21 13:27:40 +0530 |
commit | e0ddbd02bd1c365b95bb88eaa6e4e0238faf35eb (patch) | |
tree | 8035bea649dee8e517380a8c3d6dc31a0436c2c3 /yt_dlp/utils.py | |
parent | 0bfc53d05c7ecd7762313f0cd8578c46cd916519 (diff) | |
download | hypervideo-pre-e0ddbd02bd1c365b95bb88eaa6e4e0238faf35eb.tar.lz hypervideo-pre-e0ddbd02bd1c365b95bb88eaa6e4e0238faf35eb.tar.xz hypervideo-pre-e0ddbd02bd1c365b95bb88eaa6e4e0238faf35eb.zip |
[cleanup] Use format_field where applicable
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index cb44a9c51..55bd67ea2 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -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): |