sjdonado / idonthavespotify

Effortlessly convert Spotify links to your preferred streaming service
https://idonthavespotify.donado.co
37 stars 2 forks source link

Feat/#7 parse mobile links #9

Closed sjdonado closed 11 months ago

sjdonado commented 11 months ago

Thanks to this hint from the description of #7

Unfortunately, after that it's not as simple as updating the fetch call to fetch(spotifyLink, { redirect: 'follow' }) as it redirects to a page that tries to open the app or show a button with a link to the correct URL. (I would use a[href^=https://open.spotify.com to get this)

this issue was addressed in no time :)

This PR updates parseSpotifyMetadata, to check if the link has the mobile format and then execute one extra request to get the desktop link (which is the only one that returns the required metadata).

The api/search endpoint has also been updated to validate the API version and the HTTP GET verb has been replaced by POST to support spotify links with query params.

Coverage is virtually 100%, so I'm confident that we can merge without side effects.

closes #7