1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-06 13:28:22 -04:00

[cleanup] Misc (#5044)

Authored by: gamer191, pukkandan
This commit is contained in:
gamer191
2022-10-04 15:23:11 +11:00
committed by GitHub
parent 878eac3e2e
commit 304ad45a9b
20 changed files with 50 additions and 53 deletions

View File

@@ -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()