diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 018c680d7..6a60b9fb6 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -113,6 +113,7 @@ from .version import __version__ if compat_os_name == 'nt': import ctypes + class YoutubeDL(object): """YoutubeDL class. @@ -824,7 +825,7 @@ class YoutubeDL(object): self.report_error(compat_str(e), e.format_traceback()) except MaxDownloadsReached: raise - except Forbidden403 as err: + except Forbidden403: # Lets not abuse of this 😜 we don't want to get brutal on the server time.sleep(random.randint(3, 13)) wrapper(self, *args, **kwargs) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index fcd619373..e1bd67919 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -481,5 +481,4 @@ def main(argv=None): sys.exit('\nERROR: Interrupted by user') - __all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors'] diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index d83873339..90a178c73 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -2997,9 +2997,11 @@ else: def compat_ctypes_WINFUNCTYPE(*args, **kwargs): return ctypes.WINFUNCTYPE(*args, **kwargs) + # Implement an error for which it is raise when error code 403 HTTPError class Forbidden403(Exception): - pass + pass + __all__ = [ 'compat_HTMLParseError', diff --git a/youtube_dl/downloader/http.py b/youtube_dl/downloader/http.py index f8f5cb9fa..86d6f3441 100644 --- a/youtube_dl/downloader/http.py +++ b/youtube_dl/downloader/http.py @@ -187,7 +187,7 @@ class HttpFD(FileDownloader): elif err.code != 403 and (err.code < 500 or err.code >= 600): # Unexpected HTTP error raise - elif err.code == 403: # The famous 403 Forbidden error + elif err.code == 403: # The famous 403 Forbidden error raise Forbidden403 raise RetryDownload(err) except socket.error as err: