RustyRin / bandcamp-api

A simple way to get info from Bandcamp
GNU General Public License v3.0
11 stars 4 forks source link

artist link fails, you need album link for get_artist #5

Closed matkoniecz closed 1 year ago

matkoniecz commented 1 year ago
from bandcamp_api import Bandcamp
bc = Bandcamp()
data = bc.get_artist(artist_url = "https://sabaton.bandcamp.com/album/the-unkillable-soldier")
data = bc.get_artist(artist_url = "https://sabaton.bandcamp.com/")

Second query fails.

  File "/home/mateusz/.local/lib/python3.8/site-packages/bandcamp_api/bandcamp_api.py", line 55, in get_artist
    return Artist(artist_url=artist_url)
  File "/home/mateusz/.local/lib/python3.8/site-packages/bandcamp_api/artist.py", line 74, in __init__
    raise AttributeError("Either the Artist URL given is either private, deleted or the link is malformed")
AttributeError: Either the Artist URL given is either private, deleted or the link is malformed
matkoniecz commented 1 year ago

Note that it is what

from bandcamp_api import Bandcamp
bc = Bandcamp()
results = bc.search_artist(search_term)
for entry in results:
    print(entry.artist_url)

gives us and there is no obvious way to get ling with album suffix

RustyRin commented 1 year ago

I've looked into this last night.
There is a script tag that is used to get artist info that only exists when viewing an album.

I have been (slowly) working on moving more of the code to use the api calls that the iOS app uses.

Currently, the band-aid fix is just to use some random album instead of the base artist url

matkoniecz commented 1 year ago

just to use some random album instead of the base artist url

The tricky part is how to obtain album of artist if you cannot fetch artist data

RustyRin commented 1 year ago

Just use the album link.
But with the api call uses numerical band ids, so in the future getartist will prob just be a fancy way to say grab the first search result.
Same goes with all of the get
functions tbh

matkoniecz commented 1 year ago

Just use the album link.

Yes, but getting it is a bit tricky (I want to find which of some music set is available from Bandcamp, and currently I search by artist name). I do not have album data in this dataset.

RustyRin commented 1 year ago

okay, i fixed this. i even added support for /music urls