[GH-ISSUE #1216] Support Spotify Web API #689

Closed
opened 2026-02-26 02:33:58 +03:00 by kerem · 17 comments
Owner

Originally created by @phanan on GitHub (Apr 18, 2020).
Original GitHub issue: https://github.com/koel/koel/issues/1216

Description
Currently, Koel makes use of Last.fm API (when properly configured) for extra artist and album information. However, Last.fm has updated their API terms of use, with the most relevant change being artist/album images replaced by a generic star:

image

Though not critical, this change hinders the user experience quite a bit. At the same time, Last.fm is slowly but steadily degrading as a service and lagging far behind competitors, the most significant being Spotify.

It's about time Koel starts to support Spotify Web API. Our target is to have feature parity with the existing Last.fm support. A "Connect to Spotify" should be available in User's profile, enabling user authenication. For Spotify API calls, jwilsson/spotify-web-api-php looks promising.

Originally created by @phanan on GitHub (Apr 18, 2020). Original GitHub issue: https://github.com/koel/koel/issues/1216 **Description** Currently, Koel makes use of Last.fm API (when properly configured) for extra artist and album information. However, Last.fm has [updated their API terms of use](https://getsatisfaction.com/lastfm/topics/api-announcement-dac8oefw5vrxq), with the most relevant change being artist/album images replaced by a generic star: ![image](https://user-images.githubusercontent.com/8056274/79640218-a8790a80-8190-11ea-97de-dd1ba7edf837.png) Though not critical, this change hinders the user experience quite a bit. At the same time, Last.fm is slowly but steadily degrading as a service and lagging far behind competitors, the most significant being Spotify. It's about time Koel starts to support [Spotify Web API](https://developer.spotify.com/documentation/web-api/). Our target is to have feature parity with the existing Last.fm support. A "Connect to Spotify" should be available in User's profile, enabling user authenication. For Spotify API calls, [jwilsson/spotify-web-api-php](https://github.com/jwilsson/spotify-web-api-php) looks promising.
Author
Owner

@sharik709 commented on GitHub (Jan 16, 2021):

This is interesting. Would love this. I'm gonna work on it.

<!-- gh-comment-id:761692278 --> @sharik709 commented on GitHub (Jan 16, 2021): This is interesting. Would love this. I'm gonna work on it.
Author
Owner

@nielsdrost7 commented on GitHub (Sep 26, 2021):

@sharik709 did you start to work on it? Do you have time for it? Let me know
@phanan I can't take on the frontend part, but I could use on the backend, once I know if Sharik is working on it or not

<!-- gh-comment-id:927303361 --> @nielsdrost7 commented on GitHub (Sep 26, 2021): @sharik709 did you start to work on it? Do you have time for it? Let me know @phanan I can't take on the frontend part, but I could use on the backend, once I know if Sharik is working on it or not
Author
Owner

@sharik709 commented on GitHub (Sep 26, 2021):

Hello, I wanted to but didn't have time. I have time for it now.

On Sun, 26 Sep, 2021, 6:34 PM Niels Drost, @.***> wrote:

@sharik709 https://github.com/sharik709 did you start to work on it? Do
you have time for it? Let me know


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1216#issuecomment-927303361, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ADL4M2I3SUUH3WVGKLGB4VTUD4K5XANCNFSM4MLL62NQ
.

<!-- gh-comment-id:927308819 --> @sharik709 commented on GitHub (Sep 26, 2021): Hello, I wanted to but didn't have time. I have time for it now. On Sun, 26 Sep, 2021, 6:34 PM Niels Drost, ***@***.***> wrote: > @sharik709 <https://github.com/sharik709> did you start to work on it? Do > you have time for it? Let me know > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1216#issuecomment-927303361>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ADL4M2I3SUUH3WVGKLGB4VTUD4K5XANCNFSM4MLL62NQ> > . >
Author
Owner

@nielsdrost7 commented on GitHub (Sep 26, 2021):

t didn't have time. I have time for it n

Ok, great, man! Let's collaborate. I'll set up a repository and I will add you. To be continued 😄

<!-- gh-comment-id:927315801 --> @nielsdrost7 commented on GitHub (Sep 26, 2021): > t didn't have time. I have time for it n Ok, great, man! Let's collaborate. I'll set up a repository and I will add you. To be continued :smile:
Author
Owner

@sharik709 commented on GitHub (Sep 26, 2021):

Sounds good, thanks!

On Sun, 26 Sep, 2021, 8:01 PM Niels Drost, @.***> wrote:

t didn't have time. I have time for it n

Ok, great, man! Let's collaborate. I'll set up a repository and I will add
you. To be continued :-)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/koel/koel/issues/1216#issuecomment-927315801, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ADL4M2MH2GUISY7AJY5OQQDUD4VFZANCNFSM4MLL62NQ
.

<!-- gh-comment-id:927316125 --> @sharik709 commented on GitHub (Sep 26, 2021): Sounds good, thanks! On Sun, 26 Sep, 2021, 8:01 PM Niels Drost, ***@***.***> wrote: > t didn't have time. I have time for it n > > Ok, great, man! Let's collaborate. I'll set up a repository and I will add > you. To be continued :-) > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/koel/koel/issues/1216#issuecomment-927315801>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ADL4M2MH2GUISY7AJY5OQQDUD4VFZANCNFSM4MLL62NQ> > . >
Author
Owner

@nielsdrost7 commented on GitHub (Sep 26, 2021):

So I've created a branch in the repository. I've just added you.
This is what I've had in mind:

  • Add jwilsson/spotify-web-api-php

  • In order to get an access token from Spotify you need to create an 'application' with spotify (in the development.spotify.com url)
    An example route could be:
    Route::group(['prefix' => 'spotify'], static function (): void { Route::get('connect', 'SpotifyController@connect')->name('spotify.connect'); Route::get('callback', 'SpotifyController@callback')->name('spotify.callback'); });

  • Make a SpotifyController with those functions and store the access token and refresh token in the cache.

  • Make several controllers for the Spotify functions (in that jwilsson package)

I will work on adding that SpotifyController, so we'll have a base.
I will let you know once I'm done.

Let's both make pull-requests towards the feature/add-spotify-api branch (in that new repository). Then make the branch perfect at the end and make a pull-request for this issue. If that makes sense.

<!-- gh-comment-id:927317893 --> @nielsdrost7 commented on GitHub (Sep 26, 2021): So I've created a branch in the repository. I've just added you. This is what I've had in mind: - Add jwilsson/spotify-web-api-php - In order to get an access token from Spotify you need to create an 'application' with spotify (in the development.spotify.com url) An example route could be: ` Route::group(['prefix' => 'spotify'], static function (): void { Route::get('connect', 'SpotifyController@connect')->name('spotify.connect'); Route::get('callback', 'SpotifyController@callback')->name('spotify.callback'); });` - Make a SpotifyController with those functions and store the access token and refresh token in the cache. - Make several controllers for the Spotify functions (in that jwilsson package) _I will work on_ adding that SpotifyController, so we'll have a base. I will let you know once I'm done. Let's both make pull-requests towards the feature/add-spotify-api branch (in that new repository). Then make the branch perfect at the end and make a pull-request for this issue. If that makes sense.
Author
Owner

@sharik709 commented on GitHub (Sep 26, 2021):

Sure, Makes perfect sense to me. If I understand it right, I'm supposed to manage the auth part and create a bridge between koel to Spotify and you would connect that bridge with Koel's internal functions, correct?

<!-- gh-comment-id:927319246 --> @sharik709 commented on GitHub (Sep 26, 2021): Sure, Makes perfect sense to me. If I understand it right, I'm supposed to manage the auth part and create a bridge between koel to Spotify and you would connect that bridge with Koel's internal functions, correct?
Author
Owner

@nielsdrost7 commented on GitHub (Sep 26, 2021):

I'm supposed to manage the auth part and create a bridge between koel to Spotify

Yes, let's do that. Let me know if you need any help.

<!-- gh-comment-id:927320449 --> @nielsdrost7 commented on GitHub (Sep 26, 2021): > I'm supposed to manage the auth part and create a bridge between koel to Spotify Yes, let's do that. Let me know if you need any help.
Author
Owner

@sharik709 commented on GitHub (Sep 26, 2021):

ok, Thanks!

<!-- gh-comment-id:927320800 --> @sharik709 commented on GitHub (Sep 26, 2021): ok, Thanks!
Author
Owner

@nielsdrost7 commented on GitHub (Oct 2, 2021):

@sharik709 how is it going?
I realize that the auth part for the Spotify API is really complicated, so if you haven't created it yet, just let me know.
I had to prepare for the internal functions for Koel, so I might give you a few steps in the right direction for the auth part.

Just let me know, ok 😄

<!-- gh-comment-id:932691423 --> @nielsdrost7 commented on GitHub (Oct 2, 2021): @sharik709 how is it going? I realize that the auth part for the Spotify API is really complicated, so if you haven't created it yet, just let me know. I had to prepare for the internal functions for Koel, so I might give you a few steps in the right direction for the auth part. Just let me know, ok :smile:
Author
Owner

@sharik709 commented on GitHub (Oct 2, 2021):

Hi @nielsdrost7
Thank you for your message. I have reviewed it and started with small work. As of this moment, I'm not struggling with anything, I think I can pull it off.

Thanks :)

<!-- gh-comment-id:932778334 --> @sharik709 commented on GitHub (Oct 2, 2021): Hi @nielsdrost7 Thank you for your message. I have reviewed it and started with small work. As of this moment, I'm not struggling with anything, I think I can pull it off. Thanks :)
Author
Owner

@sharik709 commented on GitHub (Oct 3, 2021):

Hello @nielsdrost7
I've created a new branch spotify/auth in the repo you shared. I'm trying to add support for connect and callback but when I try to hit the URL it just redirects me to the home page. Unable to figure out what could be the cause of it. Can you please check the code in my commit (Only commit) and tell me what did I do wrong?

Thank you :)

<!-- gh-comment-id:932878298 --> @sharik709 commented on GitHub (Oct 3, 2021): Hello @nielsdrost7 I've created a new branch `spotify/auth` in the repo you shared. I'm trying to add support for connect and callback but when I try to hit the URL it just redirects me to the home page. Unable to figure out what could be the cause of it. Can you please check the code in my commit (Only commit) and tell me what did I do wrong? Thank you :)
Author
Owner

@nielsdrost7 commented on GitHub (Oct 4, 2021):

@sharik709 of course I will. I will let you know as soon as I know something

<!-- gh-comment-id:933133613 --> @nielsdrost7 commented on GitHub (Oct 4, 2021): @sharik709 of course I will. I will let you know as soon as I know something
Author
Owner

@nielsdrost7 commented on GitHub (Oct 6, 2021):

@sharik709 great job, man! I created a PR, so I can comment more easily to your branch.
I mentioned you in that PR, so I think you will have gotten an email for that.

In order to check those newly created urls, do the following:

  • Open resources/assets/js/router.ts in your favorite editor
  • Find loadState (): void { if (!window.location.hash) { return this.go('home') }
  • Comment out the part if (!window.location.hash) { return this.go('home') }
  • Then run yarn build or yarn watch or something. The assets need to be rebuilt
  • Eventually you can run /spotify/connect and get an authorizationUrl, which will give you spotify/callback
  • catch the code you'll get from Spotify.

Let me know if you need help. This is fun!

<!-- gh-comment-id:935781941 --> @nielsdrost7 commented on GitHub (Oct 6, 2021): @sharik709 great job, man! I created a PR, so I can comment more easily to your branch. I mentioned you in that PR, so I think you will have gotten an email for that. In order to check those newly created urls, do the following: - Open `resources/assets/js/router.ts` in your favorite editor - Find ```loadState (): void { if (!window.location.hash) { return this.go('home') }``` - Comment out the part ```if (!window.location.hash) { return this.go('home') }``` - Then run `yarn build` or `yarn watch` or something. The assets need to be rebuilt - Eventually you can run /spotify/connect and get an authorizationUrl, which will give you `spotify/callback` - catch the code you'll get from Spotify. Let me know if you need help. This is fun!
Author
Owner

@sharik709 commented on GitHub (Oct 7, 2021):

Awesome, thanks! :)

<!-- gh-comment-id:937669360 --> @sharik709 commented on GitHub (Oct 7, 2021): Awesome, thanks! :)
Author
Owner

@nielsdrost7 commented on GitHub (Oct 24, 2021):

@sharik709 how is it going with applying those changes in your branch?

<!-- gh-comment-id:950293158 --> @nielsdrost7 commented on GitHub (Oct 24, 2021): @sharik709 how is it going with applying those changes in your branch?
Author
Owner

@phanan commented on GitHub (Aug 9, 2022):

Initial Spotify support has landed in v6.

<!-- gh-comment-id:1209918158 --> @phanan commented on GitHub (Aug 9, 2022): Initial Spotify support has landed in v6.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#689
No description provided.