car-talk-downloader: improve logging on errors
This commit is contained in:
parent
1cd2ec48b3
commit
7009457ac2
@ -206,6 +206,7 @@ def download_episode(
|
|||||||
return episode, "dry-run"
|
return episode, "dry-run"
|
||||||
|
|
||||||
url = unescape_audio_url(episode.audio_url)
|
url = unescape_audio_url(episode.audio_url)
|
||||||
|
err_msg = ""
|
||||||
for attempt in range(retries + 1):
|
for attempt in range(retries + 1):
|
||||||
if attempt:
|
if attempt:
|
||||||
delay = min(10.0, (2**attempt)) + random.random()
|
delay = min(10.0, (2**attempt)) + random.random()
|
||||||
@ -244,11 +245,12 @@ def download_episode(
|
|||||||
size_kb = final_path.stat().st_size / 1024.0
|
size_kb = final_path.stat().st_size / 1024.0
|
||||||
logger.info("Saved %s (%.1f KB) in %.2fs", final_path, size_kb, elapsed)
|
logger.info("Saved %s (%.1f KB) in %.2fs", final_path, size_kb, elapsed)
|
||||||
return episode, "ok"
|
return episode, "ok"
|
||||||
except (urllib.error.URLError, TimeoutError, OSError):
|
except (urllib.error.URLError, TimeoutError, OSError) as exc:
|
||||||
temp_path.unlink(missing_ok=True)
|
temp_path.unlink(missing_ok=True)
|
||||||
|
err_msg = str(exc)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.error("Failed after retries: %s", filename)
|
logger.error("Failed after retries: %s: %s", filename, err_msg)
|
||||||
return episode, "fail"
|
return episode, "fail"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user