meeb / bandcampsync

Downloads your Bandcamp purchases automatically
BSD 3-Clause "New" or "Revised" License
142 stars 7 forks source link

Sync fails if download has been requested too many times #14

Closed disconnect78 closed 11 months ago

disconnect78 commented 11 months ago

Running 0.3.5 in Docker, I noticed that syncing had stopped and the container was continually restarting. Relevant logs:

2023-10-24 13:58:39,365 service [INFO] BandcampSync v0.3.5 starting
2023-10-24 13:58:39,366 service [INFO] Loaded cookies from "/config/cookies.txt"
2023-10-24 13:58:39,367 service [INFO] Time now in GB: 2023-10-24 13:58:39+01:00
2023-10-24 13:58:39,367 service [INFO] Running an initial one-off synchronisation immediately
2023-10-24 13:58:39,367 service [INFO] Starting synchronisation
2023-10-24 13:58:39,367 media [INFO] Local media directory: /downloads
...
2023-10-24 13:58:44,868 bandcamp [INFO] Found item: DISCHORDIA / Triptych (id:2177694343)
...
2023-10-24 13:58:46,556 sync [INFO] Downloading item "DISCHORDIA / Triptych" (id:2177694343) from https://popplers5.bandcamp.com/download/album?enc=flac&id=2177694343&payment_id=_REDACTED_&sig=[masked] to /var/tmp/tmpkpfo6pc3
Traceback (most recent call last):
  File "/usr/local/bin/bandcampsync-service", line 74, in <module>
    do_sync(cookies_path, cookies, dir_path, media_format_env, temp_dir)
  File "/usr/local/lib/python3.11/dist-packages/bandcampsync/__init__.py", line 42, in do_sync
    download_file(download_file_url, temp_file)
  File "/usr/local/lib/python3.11/dist-packages/bandcampsync/download.py", line 43, in download_file
    r.raise_for_status()
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://popplers5.bandcamp.com/download/album?enc=flac&id=2177694343&payment_id=_REDACTED_&sig=_REDACTED_

At this point it bombs out and restarts the container, causing it to happen again and again.

Checking the download page on bandcamp shows this error:

image

For the time being I've manually created a bandcamp_item_id.txt file to skip the dl; is it worth adding error handling to (temporarily?) skip downloads that fetch a 403 response?

(For reference, I think it ended up in this state because I ran out of room on the download drive while it was running overnight. So it would start to download that album, bomb out due to lack of space, restart the container, try the download again etc.)

meeb commented 11 months ago

Ah, thanks I'll add a skip on 403's.