mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-30 14:15:13 +00:00
[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,a825ffbffa (commitcomment-68538986), https://github.com/yt-dlp/yt-dlp/issues/2360,5fa3c9a88f (r70393519),5fa3c9a88f (r70393254)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user