Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotify short link support to get track - missing #154

Closed
rakeshparveen5 opened this issue Apr 2, 2023 · 9 comments · Fixed by #200
Closed

Spotify short link support to get track - missing #154

rakeshparveen5 opened this issue Apr 2, 2023 · 9 comments · Fixed by #200

Comments

@rakeshparveen5
Copy link

To get the spotify track we can use the trackId , but now found that the official Spotify mobile app can create short links for the track. Same short links can't interpreted by this package Or please share the methods if there is any support for this.
Thanks

@rinukkusu
Copy link
Owner

rinukkusu commented Apr 9, 2023

@rakeshparveen5 For reference can you share how such a shortlink looks like?

I get this for instance, when I press share on a song, which seems to just include the track id:

https://open.spotify.com/track/4lSUnT4x3ilmPKL2USgxjy

Of couse there also are the Spotify URIs, but these also contain the track id or whatever entity it is, that is being shared:

spotify:track:6rqhFgbbKwnb9MLmUQDhG6

@rakeshparveen5
Copy link
Author

The short link provided by spotify mobile app : https://spotify.link/hRkBrwub9xb

@rinukkusu
Copy link
Owner

rinukkusu commented Apr 9, 2023

Hmmm, I don't think there is an official API for that at the moment...

Edit: after some more research I found this - maybe it helps upvoting this issue https://community.spotify.com/t5/Spotify-for-Developers/Give-us-an-endpoint-to-decode-new-shortened-share-links/td-p/5523686

@hayribakici

This comment was marked as resolved.

@hayribakici hayribakici added the blocked Issues that are blocked by other issues label Sep 21, 2023
@henryssunday
Copy link

henryssunday commented Oct 12, 2023

@hayribakici if you add the following header to your head request: "User-Agent": "curl/7.79.1" then Spotify will return the real url of the track/album/whatever.
Example:

Future<String> getExpandedUri(String url) {
Dio dio = Dio();
    dio.options.followRedirects = true;
    dio.options.maxRedirects = 10;
    Response<void> response = await dio.head(url,
        options: Options(headers: {"User-Agent": "curl/7.79.1"}));
    if (response.statusCode == 200) {
      return response.realUri.toString();
    } else {
      throw Exception();
    }
}

@hayribakici
Copy link
Collaborator

hayribakici commented Nov 20, 2023

@tomcruisesfronttooth thank you, however the solution requires the dio package. Since this library uses http, this issue is still blocked (see the above comment).


@rinukkusu (out of curiosity) do we still need the labels unclear and spotify issue for this?

@hayribakici
Copy link
Collaborator

hayribakici commented Feb 6, 2024

I have good news regarding this issue. There is a merged PR in dart-lang/http#1109, that introduces a new class BaseResponseWithUrl, which contains a redirected url in the response. I'll remove the blocked label, so this can be feature can be implemented. I'll create a new issue for this.

@rinukkusu could this redirection of the url be used to retrieve the redirect url from the oauth authorization? If so, than we could implement a more streamlined authorization.

@rinukkusu
Copy link
Owner

Maybe it could be used for that as well! I'm really not an oauth expert tbh and glad that this got implemented by community members that seem to know what they are doing 😆

@hayribakici
Copy link
Collaborator

Yeah, I am also no oauth expert 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants