aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-03-27 07:50:43 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-04-05 18:12:18 +0530
commita44ca5a470e09b5170fc9c3a46733f050fadbfae (patch)
treeebb38c593e2427befb3e2d15c8bf178c682a0fd4 /yt_dlp/utils.py
parent0a8a7e68fabf6fc9387f270301e51225ac349b00 (diff)
downloadhypervideo-pre-a44ca5a470e09b5170fc9c3a46733f050fadbfae.tar.lz
hypervideo-pre-a44ca5a470e09b5170fc9c3a46733f050fadbfae.tar.xz
hypervideo-pre-a44ca5a470e09b5170fc9c3a46733f050fadbfae.zip
[cleanup] Misc fixes
Closes https://github.com/yt-dlp/yt-dlp/pull/3213, Closes https://github.com/yt-dlp/yt-dlp/pull/3117 Related: https://github.com/yt-dlp/yt-dlp/issues/3146#issuecomment-1077323114, https://github.com/yt-dlp/yt-dlp/pull/3277#discussion_r841019671, https://github.com/yt-dlp/yt-dlp/commit/a825ffbffa0bea322e3ccb44c6f8e01d8d9572fb#commitcomment-68538986, https://github.com/yt-dlp/yt-dlp/issues/2360, https://github.com/yt-dlp/yt-dlp/commit/5fa3c9a88f597625296981a4a26be723e65d4842#r70393519, https://github.com/yt-dlp/yt-dlp/commit/5fa3c9a88f597625296981a4a26be723e65d4842#r70393254
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index ce918750d..6663583fc 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -1040,7 +1040,7 @@ def make_HTTPS_handler(params, **kwargs):
def bug_reports_message(before=';'):
- msg = ('please report this issue on https://github.com/yt-dlp/yt-dlp , '
+ msg = ('please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , '
'filling out the appropriate issue template. '
'Confirm you are on the latest version using yt-dlp -U')
@@ -2883,6 +2883,7 @@ class PagedList:
class OnDemandPagedList(PagedList):
+ """Download pages until a page with less than maximum results"""
def _getslice(self, start, end):
for pagenum in itertools.count(start // self._pagesize):
firstid = pagenum * self._pagesize
@@ -2922,6 +2923,7 @@ class OnDemandPagedList(PagedList):
class InAdvancePagedList(PagedList):
+ """PagedList with total number of pages known in advance"""
def __init__(self, pagefunc, pagecount, pagesize):
PagedList.__init__(self, pagefunc, pagesize, True)
self._pagecount = pagecount
@@ -3090,13 +3092,10 @@ def multipart_encode(data, boundary=None):
def dict_get(d, key_or_keys, default=None, skip_false_values=True):
- if isinstance(key_or_keys, (list, tuple)):
- for key in key_or_keys:
- if key not in d or d[key] is None or skip_false_values and not d[key]:
- continue
- return d[key]
- return default
- return d.get(key_or_keys, default)
+ for val in map(d.get, variadic(key_or_keys)):
+ if val is not None and (val or not skip_false_values):
+ return val
+ return default
def try_call(*funcs, expected_type=None, args=[], kwargs={}):
@@ -3324,6 +3323,10 @@ def error_to_compat_str(err):
return err_str
+def error_to_str(err):
+ return f'{type(err).__name__}: {err}'
+
+
def mimetype2ext(mt):
if mt is None:
return None