Lower to 3 attempts

This commit is contained in:
Joshua Boniface 2023-04-03 04:59:03 -04:00
parent f3b4119e1a
commit 8365ed51a6
1 changed files with 4 additions and 4 deletions

8
c3dbdl
View File

@ -31,9 +31,9 @@ def buildDatabase(pages=None):
for i in range(1, pages + 1): for i in range(1, pages + 1):
attempts = 1 attempts = 1
p = None p = None
while attempts <= 5: while attempts <= 3:
try: try:
click.echo(f"Parsing page {i} (attempt #{attempts})...") click.echo(f"Parsing page {i} (attempt {attempts}/3)...")
p = requests.get(f"{config['base_songs_url']}?page={i}") p = requests.get(f"{config['base_songs_url']}?page={i}")
break break
except Exception: except Exception:
@ -121,12 +121,12 @@ def downloadSong(destination, filename, entry):
p = None p = None
try: try:
with requests.get(download_url, stream=True) as r: with requests.get(download_url, stream=True) as r:
while attempts <= 5: while attempts <= 3:
try: try:
r.raise_for_status() r.raise_for_status()
break break
except Exception: except Exception:
click.echo(f"Download attempt failed: HTTP {r.status_code}; retrying {attempts}/5") click.echo(f"Download attempt failed: HTTP {r.status_code}; retrying {attempts}/3")
sleep(attempts) sleep(attempts)
attempts += 1 attempts += 1
if r is None or r.status_code != 200: if r is None or r.status_code != 200: