Skip to content

Commit

Permalink
utils (RetryManager): quick fix for error message manuplation
Browse files Browse the repository at this point in the history
e.cause is actually HTTPError, causing this error:

  File "/home/lesmi/yt-dlp/yt_dlp/utils.py", line 5729, in __iter__
    self.error_callback(self.error, self.attempt, self.retries)
  File "/home/lesmi/yt-dlp/yt_dlp/extractor/common.py", line 3853, in _error_or_warning
    RetryManager.report_retry(err, _count or int(fatal), _retries, info=self.to_screen, warn=self.report_warning,
  File "/home/lesmi/yt-dlp/yt_dlp/utils.py", line 5742, in report_retry
    e = remove_end(e.cause or e.orig_msg, '.')
  File "/home/lesmi/yt-dlp/yt_dlp/utils.py", line 2394, in remove_end
    return s[:-len(end)] if s is not None and s.endswith(end) else s
  File "/usr/lib/python3.10/tempfile.py", line 617, in __getattr__
    a = getattr(file, name)
  File "/usr/lib/python3.10/tempfile.py", line 617, in __getattr__
    a = getattr(file, name)
AttributeError: '_io.BytesIO' object has no attribute 'endswith'
  • Loading branch information
Lesmiscore committed Aug 4, 2022
1 parent 6a2fd9f commit 272b4c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yt_dlp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5801,7 +5801,8 @@ def report_retry(e, count, retries, *, sleep_func, info, warn, error=None, suffi
if not count:
return warn(e)
elif isinstance(e, ExtractorError):
e = remove_end(e.cause or e.orig_msg, '.')
msg = try_get(e, (lambda x: e.cause.read(), lambda x: e.cause, lambda x: e.orig_msg), str)
e = remove_end(msg, '.')
warn(f'{e}. Retrying{format_field(suffix, None, " %s")} ({count}/{retries})...')

delay = float_or_none(sleep_func(n=count - 1)) if callable(sleep_func) else sleep_func
Expand Down

0 comments on commit 272b4c1

Please sign in to comment.