ROpdebee / mb-userscripts

Collection of userscripts for MusicBrainz
MIT License
119 stars 9 forks source link

Extract Bandcamp track images more efficiently #765

Open kellnerd opened 5 months ago

kellnerd commented 5 months ago

Instead of extracting each image from the HTML page of its track (one additional request per track), they can also be extracted from the embedded player (one additional request in total). This approach even works for pre-releases where the files have already been uploaded although the track pages themselves are not even accessible before the release.

An embedded player can be fetched from https://bandcamp.com/EmbeddedPlayer/album=${albumId}, where albumId is the numeric internal ID from the tralbum JSON. The interesting JSON data is embedded into a player-data data attribute on that HTML page.

Example: https://chillhop.bandcamp.com/album/chillhop-essentials-summer-2024 -> https://bandcamp.com/EmbeddedPlayer/album=3871800458

Unfortunately the embedded player JSON data includes a lot of bloat about any(?) merch offered by that artist/label for whatever reason, but this is still more efficient than downloading the HTML of each track.