BandcampEnhancementSuite
BandcampEnhancementSuite copied to clipboard
collection summary
there is an API endpoint that is only available to the user that is logged in:
import requests
from typing import Any, Optional
def fetch_collection_summary() -> Optional[Any]:
url = "https://bandcamp.com/api/fan/2/collection_summary"
headers = {
"authority": "bandcamp.com",
"accept": "application/json, text/javascript, */*; q=0.01",
"accept-language": "en-US,en;q=0.9",
"referer": "https://bandcamp.com/dataist",
"sec-ch-ua": "\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
"x-requested-with": "XMLHttpRequest",
}
cookies = {
"client_id": client_id,
"fan_visits": fan_id"896389",
"identity": identity,
"js_logged_in": "1",
}
response = requests.get(url, headers=headers, cookies=cookies)
if response.status_code != 200:
print(f"Failed to get data: {response.status_code}")
return None
return response.json()
if __name__ == "__main__":
collection_summary = fetch_collection_summary()
print(collection_summary)
the problem with this one is there is no way to use different user ids. It's tied to the logged in user. However, this could be useful for caching with a server to provide suggestions for tracks.