mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-05 21:14:52 +00:00

committed by
GitHub

parent
a539f06570
commit
3e9b66d761
@@ -2554,6 +2554,13 @@ def url_or_none(url):
|
||||
return url if re.match(r'^(?:(?:https?|rt(?:m(?:pt?[es]?|fp)|sp[su]?)|mms|ftps?):)?//', url) else None
|
||||
|
||||
|
||||
def request_to_url(req):
|
||||
if isinstance(req, compat_urllib_request.Request):
|
||||
return req.get_full_url()
|
||||
else:
|
||||
return req
|
||||
|
||||
|
||||
def strftime_or_none(timestamp, date_format, default=None):
|
||||
datetime_object = None
|
||||
try:
|
||||
@@ -5172,6 +5179,22 @@ 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 decode_base(value, digits):
|
||||
# This will convert given base-x string to scalar (long or int)
|
||||
table = {char: index for index, char in enumerate(digits)}
|
||||
result = 0
|
||||
base = len(digits)
|
||||
for chr in value:
|
||||
result *= base
|
||||
result += table[chr]
|
||||
return result
|
||||
|
||||
|
||||
def time_seconds(**kwargs):
|
||||
t = datetime.datetime.now(datetime.timezone(datetime.timedelta(**kwargs)))
|
||||
return t.timestamp()
|
||||
|
||||
|
||||
# create a JSON Web Signature (jws) with HS256 algorithm
|
||||
# the resulting format is in JWS Compact Serialization
|
||||
# implemented following JWT https://www.rfc-editor.org/rfc/rfc7519.html
|
||||
|
Reference in New Issue
Block a user