1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

allow '-1' for infinite retries (#300)

This commit is contained in:
Mike Fährmann 2019-06-30 22:55:31 +02:00
parent f7b5c4c3e7
commit 69205df68d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
5 changed files with 14 additions and 5 deletions

View File

@ -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.
=========== =====
@ -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.
=========== =====

View File

@ -30,6 +30,8 @@ class HttpDownloader(DownloaderBase):
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:

View File

@ -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,

View File

@ -43,6 +43,9 @@ class Extractor():
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):

View File

@ -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",