Lower to 3 attempts
This commit is contained in:
parent
f3b4119e1a
commit
8365ed51a6
8
c3dbdl
8
c3dbdl
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue