diff options
author | gamer191 <83270075+gamer191@users.noreply.github.com> | 2022-10-04 15:23:11 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-04 09:53:11 +0530 |
commit | 304ad45a9b18cba7b62e7cb435fb0ddc49003ed7 (patch) | |
tree | b4442d5e85a30db771362b6b9ea3d703fe1b5145 /yt_dlp/utils.py | |
parent | 878eac3e2e3dfc0b811e9575056d89e19e060e79 (diff) | |
download | hypervideo-pre-304ad45a9b18cba7b62e7cb435fb0ddc49003ed7.tar.lz hypervideo-pre-304ad45a9b18cba7b62e7cb435fb0ddc49003ed7.tar.xz hypervideo-pre-304ad45a9b18cba7b62e7cb435fb0ddc49003ed7.zip |
[cleanup] Misc (#5044)
Authored by: gamer191, pukkandan
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 6cba9299a..d0be7f19e 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -3180,6 +3180,10 @@ def multipart_encode(data, boundary=None): return out, content_type +def variadic(x, allowed_types=(str, bytes, dict)): + return x if isinstance(x, collections.abc.Iterable) and not isinstance(x, allowed_types) else (x,) + + def dict_get(d, key_or_keys, default=None, skip_false_values=True): for val in map(d.get, variadic(key_or_keys)): if val is not None and (val or not skip_false_values): @@ -5446,10 +5450,6 @@ def get_first(obj, keys, **kwargs): return traverse_obj(obj, (..., *variadic(keys)), **kwargs, get_all=False) -def variadic(x, allowed_types=(str, bytes, dict)): - return x if isinstance(x, collections.abc.Iterable) and not isinstance(x, allowed_types) else (x,) - - def time_seconds(**kwargs): t = datetime.datetime.now(datetime.timezone(datetime.timedelta(**kwargs))) return t.timestamp() |