diff options
author | Lesmiscore (Naoya Ozaki) <nao20010128@gmail.com> | 2022-02-25 11:14:04 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-25 11:14:04 +0900 |
commit | 3e9b66d761048d568ed0da40e43d02e1bf02f759 (patch) | |
tree | db2e212770ab943841362eef2bcbc1d15ad6acb0 /yt_dlp/utils.py | |
parent | a539f06570e89742d641fe53328e2beea51937aa (diff) | |
download | hypervideo-pre-3e9b66d761048d568ed0da40e43d02e1bf02f759.tar.lz hypervideo-pre-3e9b66d761048d568ed0da40e43d02e1bf02f759.tar.xz hypervideo-pre-3e9b66d761048d568ed0da40e43d02e1bf02f759.zip |
[AbemaTV] Add extractors (#1688)
Authored by: Lesmiscore
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 8b0d95efa..012a115ba 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -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 |