Skip to content

Commit

Permalink
allow '-1' for infinite retries (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 30, 2019
1 parent f7b5c4c commit 69205df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions docs/configuration.rst
Expand Up @@ -301,7 +301,8 @@ extractor.*.retries
=========== =====
Type ``integer``
Default ``4``
Description Number of times a failed HTTP request is retried before giving up.
Description Maximum number of times a failed HTTP request is retried before
giving up or ``-1`` for infinite retries.
=========== =====


Expand Down Expand Up @@ -1024,7 +1025,8 @@ downloader.*.retries
=========== =====
Type ``integer``
Default `extractor.*.retries`_
Description Number of retries during file downloads.
Description Maximum number of retries during file downloads
or ``-1`` for infinite retries.
=========== =====


Expand Down
2 changes: 2 additions & 0 deletions gallery_dl/downloader/http.py
Expand Up @@ -30,6 +30,8 @@ def __init__(self, extractor, output):
self.downloading = False
self.chunk_size = 16384

if self.retries < 0:
self.retries = float("inf")
if self.rate:
self.rate = text.parse_bytes(self.rate)
if not self.rate:
Expand Down
3 changes: 2 additions & 1 deletion gallery_dl/downloader/ytdl.py
Expand Up @@ -20,10 +20,11 @@ class YoutubeDLDownloader(DownloaderBase):
def __init__(self, extractor, output):
DownloaderBase.__init__(self, extractor, output)

retries = self.config("retries", extractor._retries)
options = {
"format": self.config("format") or None,
"ratelimit": text.parse_bytes(self.config("rate"), None),
"retries": self.config("retries", extractor._retries),
"retries": retries+1 if retries >= 0 else float("inf"),
"socket_timeout": self.config("timeout", extractor._timeout),
"nocheckcertificate": not self.config("verify", extractor._verify),
"nopart": not self.part,
Expand Down
3 changes: 3 additions & 0 deletions gallery_dl/extractor/common.py
Expand Up @@ -43,6 +43,9 @@ def __init__(self, match):
self._timeout = self.config("timeout", 30)
self._verify = self.config("verify", True)

if self._retries < 0:
self._retries = float("inf")

@classmethod
def from_url(cls, url):
if isinstance(cls.pattern, str):
Expand Down
5 changes: 3 additions & 2 deletions gallery_dl/option.py
Expand Up @@ -173,8 +173,9 @@ def build_parser():
)
downloader.add_argument(
"-R", "--retries",
dest="retries", metavar="RETRIES", type=int, action=ConfigAction,
help="Number of retries (default: 4)",
dest="retries", metavar="N", type=int, action=ConfigAction,
help=("Maximum number of retries for failed HTTP requests "
"or -1 for infinite retries (default: 4)"),
)
downloader.add_argument(
"-A", "--abort",
Expand Down

0 comments on commit 69205df

Please sign in to comment.