meeb / bandcampsync

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

Error caused by lack of downloadable content for an album #4

Closed markHadman closed 1 year ago

markHadman commented 1 year ago

I'm getting stuck on this one every time. I'm far from sure, but guessing it might be the '?' in the album title

2023-09-20 15:57:20,265 sync [INFO] New media item, will download: "MZYLKYPOP / Kiedy Wilki Zawyja ? "(id:4089197226) in "vorbis"
Traceback (most recent call last):
  File "/[redacted]/lib/python3.11/site-packages/bandcampsync/bandcamp.py", line 243, in get_download_file_url
    downloads = digital_item['downloads']
                ~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'downloads'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/[redacted]/bin/bandcampsync", line 41, in <module>
    do_sync(cookies_path, cookies, dir_path, media_format)
  File "[redacted]/lib/python3.11/site-packages/bandcampsync/__init__.py", line 31, in do_sync
    initial_download_url = bandcamp.get_download_file_url(item, encoding=media_format)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/[redacted]/lib/python3.11/site-packages/bandcampsync/bandcamp.py", line 245, in get_download_file_url
    raise BandcampError(f'Failed to parse pagedata JSON, does not contain an '
bandcampsync.bandcamp.BandcampError: Failed to parse pagedata JSON, does not contain an "digital_items.downloads" key
meeb commented 1 year ago

That error would imply that the album has no downloads available. I've not encountered a release without downloads so far so I wouldn't have accounted for that. When you visit your collection in Bandcamp does the release "MZYLKYPOP / Kiedy Wilki Zawyja ?" have a download link? If it does, what's visible on the download page?

If the release simply doesn't have a download option I can handle the error gracefully rather than hard exception and exiting.

markHadman commented 1 year ago

You're right, it looks like they've removed the downloadable content from this album. I'll amend the issue title (and send a snotty email to the artist)

meeb commented 1 year ago

No problem. I'll patch that to handle it with a more sensible log error rather than an exception anyway.

meeb commented 1 year ago

The above neater error log message patch will be in the next release. There's not much else I can do here to handle this. Happy to close the issue?

markHadman commented 1 year ago

I've tested your fix and it works for me. Closing, and thank you