yyyyyyyan / bandcamper

Bandcamp downloader
MIT License
44 stars 9 forks source link

Fix email download being seen as free if price is added after upload #19

Open Brisppy opened 9 months ago

Brisppy commented 9 months ago

Encountered an issue with email downloads if a price is set after the release was uploaded as free.

The email download would process as if it was available before halting with ValueError: Email download request failed: {"ok":false,"error":"Sorry, this item is no longer available for free."}

This change checks that the minimum_price is 0. I'm not sure if tracks and non-email downloads have this issue but I added the check for all types just in case.

Force-pushes were to cover potential edge cases I forgot and cover both albums and tracks all in one

yyyyyyyan commented 9 months ago

@Brisppy Can you send me an example of release which results in that?

Brisppy commented 9 months ago

Sorry forgot to include that, this one should throw it https://girlfriendrecords.bandcamp.com/album/phases.

[?] Searching available downloads for URL https://girlfriendrecords.bandcamp.com/album/phases
[+] Email download found! Downloading Linkydubs - Phases
Traceback (most recent call last):
  File "/usr/local/bin/bandcamper", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/bandcamper/__main__.py", line 169, in main
    bandcamp_downloader.download_all(destination, output, output_extra, *audio_formats)
  File "/usr/local/lib/python3.6/dist-packages/bandcamper/bandcamper.py", line 352, in download_all
    url, destination, output, output_extra, *download_formats
  File "/usr/local/lib/python3.6/dist-packages/bandcamper/bandcamper.py", line 303, in download_from_url
    url, music_data["id"], music_data["item_type"]
  File "/usr/local/lib/python3.6/dist-packages/bandcamper/bandcamper.py", line 228, in _get_download_url_from_email
    raise ValueError(f"Email download request failed: {response.text}")
ValueError: Email download request failed: {"ok":false,"error":"Sorry, this item is no longer available for free."}
Brisppy commented 9 months ago

Encountered an issue with this album where it would enter the if not music_data["current"].get("minimum_price"): block as it has no minimum_price, but failed both of the inner checks resulting in no download and a NameError as file_paths would be undefined - now fixed with https://github.com/yyyyyyyan/bandcamper/pull/19/commits/53842486337d6481b830f8a2b331e4f135071024.