spotify / spotify-web-api-ts-sdk

A Typescript SDK for the Spotify Web API with types for returned data.
Other
323 stars 58 forks source link

API fetch songs, preview url is null #86

Open rnnyrk opened 8 months ago

rnnyrk commented 8 months ago

Follow up on this closed issue on an older (but archived) official Spotify repository https://github.com/spotify/web-api/issues/148

I'm using the Credentials Flow for fetching tracks of a specific artist. Although unfortunately most preview urls (e.g. Drake, Tame Impale, 2pac, etc etc.) are empty, making my application not able to use this.

As the linked issue stated, there is a workaround fetching the embed URL and scraping the preview url from that page. But as the issue mentioned as well: "Not a fan of these kinds of workarounds but I genuinely have no idea why Spotify would make an otherwise-public information available through Authorization Code but not Client Credentials"

So it seems like the Authorization Code flow does include preview URLs, but the Client Credentials does not include those URLs. The documentation does state that it can be null, but it doesn't say why it is only null for the Client Credentials flow. There where also comments about the availableMarkets, but changing the GET parameter for market=NL or US/SE doesn't change anything in the results either.

Why is this happening? And how to potentially fix it? Or is there no other solution than scraping the embed page for the preview url? Which really is a nasty workaround for something that is build-in, but doesn't work as expected for one particular flow.

gnzchan commented 7 months ago

Having the same issues. Bumping this.

Chabma commented 7 months ago

I'm guessing this is just on purpose to discourage previews

cKarmor commented 6 months ago

Sometimes it works and other times it doesn't. For a brief period about 2 weeks ago it was working fine, now it's broke again. No one seems to have any real answer as to why nor any desire to fix it. These threads just all get referred back to a thread that doesn't help and was created almost 10 years ago so don't hold your breath for a fix.

DarthGigi commented 3 months ago

I'm having the same problem when using credentials flow. Some tracks do have an preview url, some don't.