[GH-ISSUE #196] Sync favorites with Last.fm loved tracks #141

Closed
opened 2026-02-26 02:32:15 +03:00 by kerem · 10 comments
Owner

Originally created by @ronilaukkarinen on GitHub (Jan 20, 2016).
Original GitHub issue: https://github.com/koel/koel/issues/196

I have thousands of loved tracks in last.fm, it would be wonderful to sync them with my music library. After they discontinued Last.fm radio, I have no way to play them.

In Spotify I can use Spotibot or Ivyishere and they'll match the loved tracks with songs in Spotify. To be able to import loved tracks to Koel AND add automatically loved when favorited, would be a dream come true.

Originally created by @ronilaukkarinen on GitHub (Jan 20, 2016). Original GitHub issue: https://github.com/koel/koel/issues/196 I have thousands of loved tracks in last.fm, it would be wonderful to sync them with my music library. After they discontinued Last.fm radio, I have no way to play them. In Spotify I can use [Spotibot](http://www.spotibot.com/loved/) or [Ivyishere](http://www.ivyishere.org/) and they'll match the loved tracks with songs in Spotify. To be able to import loved tracks to Koel AND add automatically loved when favorited, would be a dream come true.
kerem closed this issue 2026-02-26 02:32:15 +03:00
Author
Owner

@phanan commented on GitHub (Jan 21, 2016):

Don't think Koel will support this Last.fm-exclusive feature. I would imagine it's straightforward to do manually though: query the list of loved tracks from Last.fm (via its API perhaps), match it with Koel's database, and add a record into interactions table with each match found.

<!-- gh-comment-id:173433093 --> @phanan commented on GitHub (Jan 21, 2016): Don't think Koel will support this Last.fm-exclusive feature. I would imagine it's straightforward to do manually though: query the list of loved tracks from Last.fm (via its API perhaps), match it with Koel's database, and add a record into `interactions` table with each match found.
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 21, 2016):

Ok, too bad. That works when importing favs, but adding favs further will be a pain anyways if you suggest I'd query loved tracks back and forth every time I love a track.

Favoriting would be a single call to last.fm to love a track, just saying, at least that way I could keep track of favorites in Last.fm's side.

<!-- gh-comment-id:173482617 --> @ronilaukkarinen commented on GitHub (Jan 21, 2016): Ok, too bad. That works when importing favs, but adding favs further will be a pain anyways if you suggest I'd query loved tracks back and forth every time I love a track. Favoriting would be a single call to last.fm to love a track, just saying, at least that way I could keep track of favorites in Last.fm's side.
Author
Owner

@phanan commented on GitHub (Jan 21, 2016):

Liking a track with Koel currently already registers a favorite with
Last.fm, but not the other way around.

On Thu, Jan 21, 2016 at 3:28 PM, Roni Laukkarinen notifications@github.com
wrote:

Ok, too bad. That works when importing favs, but adding favs further will
be a pain anyways if you suggest I'd query loved tracks back and forth
every time I love a track.

Favoriting would be a single call to last.fm to love a track, just
saying, at least that way I could keep track of favorites in Last.fm's side.


Reply to this email directly or view it on GitHub
https://github.com/phanan/koel/issues/196#issuecomment-173482617.

<!-- gh-comment-id:173487262 --> @phanan commented on GitHub (Jan 21, 2016): Liking a track with Koel currently already registers a favorite with Last.fm, but not the other way around. On Thu, Jan 21, 2016 at 3:28 PM, Roni Laukkarinen notifications@github.com wrote: > Ok, too bad. That works when importing favs, but adding favs further will > be a pain anyways if you suggest I'd query loved tracks back and forth > every time I love a track. > > Favoriting would be a single call to last.fm to love a track, just > saying, at least that way I could keep track of favorites in Last.fm's side. > > — > Reply to this email directly or view it on GitHub > https://github.com/phanan/koel/issues/196#issuecomment-173482617.
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 21, 2016):

Ah, OK, did not register this before. That's awesome, thanks.
On Jan 21, 2016 9:53 AM, "Phan An" notifications@github.com wrote:

Liking a track with Koel currently already registers a favorite with
Last.fm, but not the other way around.

On Thu, Jan 21, 2016 at 3:28 PM, Roni Laukkarinen <
notifications@github.com>
wrote:

Ok, too bad. That works when importing favs, but adding favs further will
be a pain anyways if you suggest I'd query loved tracks back and forth
every time I love a track.

Favoriting would be a single call to last.fm to love a track, just
saying, at least that way I could keep track of favorites in Last.fm's
side.


Reply to this email directly or view it on GitHub
https://github.com/phanan/koel/issues/196#issuecomment-173482617.


Reply to this email directly or view it on GitHub
https://github.com/phanan/koel/issues/196#issuecomment-173487262.

<!-- gh-comment-id:173504336 --> @ronilaukkarinen commented on GitHub (Jan 21, 2016): Ah, OK, did not register this before. That's awesome, thanks. On Jan 21, 2016 9:53 AM, "Phan An" notifications@github.com wrote: > Liking a track with Koel currently already registers a favorite with > Last.fm, but not the other way around. > > On Thu, Jan 21, 2016 at 3:28 PM, Roni Laukkarinen < > notifications@github.com> > wrote: > > > Ok, too bad. That works when importing favs, but adding favs further will > > be a pain anyways if you suggest I'd query loved tracks back and forth > > every time I love a track. > > > > Favoriting would be a single call to last.fm to love a track, just > > saying, at least that way I could keep track of favorites in Last.fm's > > side. > > > > — > > Reply to this email directly or view it on GitHub > > https://github.com/phanan/koel/issues/196#issuecomment-173482617. > > — > Reply to this email directly or view it on GitHub > https://github.com/phanan/koel/issues/196#issuecomment-173487262.
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 22, 2016):

Last.fm API gives data as xml, like this:

<track>
<name>The Cloak</name>
<mbid>5df900a7-467d-4cbb-a7fe-6dcfb3d59302</mbid>
<url>http://www.last.fm/music/Leprous/_/The+Cloak</url>
<date uts="1453360544">21 Jan 2016, 07:15</date>
<artist>
<name>Leprous</name>
<mbid>a2e55cf5-ca3a-4c26-ba62-fc4a4f2bc603</mbid>
<url>http://www.last.fm/music/Leprous</url>
</artist>
<image size="small">
http://img2-ak.lst.fm/i/u/34s/57923b9081cf4229c22ac83274e6dd2a.png
</image>
<image size="medium">
http://img2-ak.lst.fm/i/u/64s/57923b9081cf4229c22ac83274e6dd2a.png
</image>
<image size="large">
http://img2-ak.lst.fm/i/u/174s/57923b9081cf4229c22ac83274e6dd2a.png
</image>
<image size="extralarge">
http://img2-ak.lst.fm/i/u/300x300/57923b9081cf4229c22ac83274e6dd2a.png
</image>
<streamable fulltrack="0">0</streamable>
</track>

What do you suggest?

<!-- gh-comment-id:173831470 --> @ronilaukkarinen commented on GitHub (Jan 22, 2016): Last.fm API gives data as xml, like this: ``` <track> <name>The Cloak</name> <mbid>5df900a7-467d-4cbb-a7fe-6dcfb3d59302</mbid> <url>http://www.last.fm/music/Leprous/_/The+Cloak</url> <date uts="1453360544">21 Jan 2016, 07:15</date> <artist> <name>Leprous</name> <mbid>a2e55cf5-ca3a-4c26-ba62-fc4a4f2bc603</mbid> <url>http://www.last.fm/music/Leprous</url> </artist> <image size="small"> http://img2-ak.lst.fm/i/u/34s/57923b9081cf4229c22ac83274e6dd2a.png </image> <image size="medium"> http://img2-ak.lst.fm/i/u/64s/57923b9081cf4229c22ac83274e6dd2a.png </image> <image size="large"> http://img2-ak.lst.fm/i/u/174s/57923b9081cf4229c22ac83274e6dd2a.png </image> <image size="extralarge"> http://img2-ak.lst.fm/i/u/300x300/57923b9081cf4229c22ac83274e6dd2a.png </image> <streamable fulltrack="0">0</streamable> </track> ``` What do you suggest?
Author
Owner

@phanan commented on GitHub (Jan 22, 2016):

Erm... Koel uses the default built-in SimpleXML.

<!-- gh-comment-id:173831889 --> @phanan commented on GitHub (Jan 22, 2016): Erm... Koel uses the default built-in [SimpleXML](http://php.net/manual/en/book.simplexml.php).
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 22, 2016):

Yes, but I meant what do you suggest in manually matching with interactions tables? how the song_id is generated and what would be the "straightforward" way to match the api output (xml) with the database? I have not gone that deep with koel insides yet.

<!-- gh-comment-id:173835238 --> @ronilaukkarinen commented on GitHub (Jan 22, 2016): Yes, but I meant what do you suggest in manually matching with `interactions` tables? how the `song_id` is generated and what would be the "straightforward" way to match the api output (xml) with the database? I have not gone that deep with koel insides yet.
Author
Owner

@phanan commented on GitHub (Jan 22, 2016):

song_id is generated based on the path of your song. So actually, you're
not creating new songs into songs table, but using the existing data.
What I would do is:

  • First, back up the database
  • Do the API call
  • With each XML node find in the API result, query (LIKE) to see if you
    have such a song in Koel
  • If the sond is found, add (or modify) the entry in interactions with
    liked=1, song_id=, user_id=

On Fri, Jan 22, 2016 at 3:40 PM, Roni Laukkarinen notifications@github.com
wrote:

Yes, but I meant what do you suggest in manually matching with
interactions tables? how the song_id is generated and what would be the
"straightforward" way to match the api output (xml) with the database? I
have not gone that deep with koel insides yet.


Reply to this email directly or view it on GitHub
https://github.com/phanan/koel/issues/196#issuecomment-173835238.

<!-- gh-comment-id:173860436 --> @phanan commented on GitHub (Jan 22, 2016): song_id is generated based on the path of your song. So actually, you're not creating new songs into `songs` table, but using the existing data. What I would do is: - First, back up the database - Do the API call - With each XML node find in the API result, query (LIKE) to see if you have such a song in Koel - If the sond is found, add (or modify) the entry in interactions with liked=1, song_id=<song ID>, user_id=<your user ID> On Fri, Jan 22, 2016 at 3:40 PM, Roni Laukkarinen notifications@github.com wrote: > Yes, but I meant what do you suggest in manually matching with > interactions tables? how the song_id is generated and what would be the > "straightforward" way to match the api output (xml) with the database? I > have not gone that deep with koel insides yet. > > — > Reply to this email directly or view it on GitHub > https://github.com/phanan/koel/issues/196#issuecomment-173835238.
Author
Owner

@ronilaukkarinen commented on GitHub (Jan 22, 2016):

OK, thanks for the tips! I'll try it soon.

<!-- gh-comment-id:173861750 --> @ronilaukkarinen commented on GitHub (Jan 22, 2016): OK, thanks for the tips! I'll try it soon.
Author
Owner

@ronilaukkarinen commented on GitHub (Feb 26, 2016):

Getting back on this.

I'm not exactly sure how to compare data and how to get koel song id from Last.fm node... would it be really much work for you to create one query for me to get all the loved tracks based on that xml output I gave?

<!-- gh-comment-id:189376433 --> @ronilaukkarinen commented on GitHub (Feb 26, 2016): Getting back on this. I'm not exactly sure how to compare data and how to get koel song id from Last.fm node... would it be really much work for you to create one query for me to get all the loved tracks based on that xml output I gave?
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#141
No description provided.