Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
2.82k stars 113 forks source link

Import Last.fm scrobbles #30

Closed durnezj closed 2 years ago

durnezj commented 3 years ago

Hello, I recently came onto this software because I was planning on building similar statistics for my own listening history, based on my last.fm scrobbles. However this web interface seems to have everything I need already. The problem is that I have over 10 years of last.fm scrobbles (48k+in total) and I would like to import them into this software. I use This Node.js tool to export them to my own servers. At first glance it seems like adding each scrobble as a datapoint would be enough for your-spotify to pick them up. Is this a correct assumption? How is the database constructed from the Spotify API? The goal is that I will script something together that can import my last.fm history into this dashboard as well. In the future this could even become a feature of this application.

Yooooomi commented 3 years ago

I really like this idea actually. The database is constructed from Spotify data, ids are Spotify ids, etc. For your thing to work, you would need to link a specific song to a Spotify song ID, by using the search API request for example. For every song, I then grab the album and the whole artist if they do not exist in the database. So, for a single Spotify song ID, I request Spotify 3 times (the song, the album, the artist) depending on if the resources already exist in the database. The interesting stuff begins here I computed the missing track ids in the database and will query everything I need. So for your thing to work, I would take from line 164 to the end of the function, with missingTrackIds being all your lastfm track converted to Spotify IDs.

I hope I have been clear and simple enough, please keep in touch if you have any trouble achieving this or if you want more information. Good luck!

durnezj commented 3 years ago

Thanks for the detailed explanation! It actually seems doable after all. When time permits me in the future, I would love to take a shot at this.

Yooooomi commented 2 years ago

Hey! It's been a while here. Last release implements full privacy import. This means that you can now import from privacy (1 year of data) and full privacy (data since account creation). I feel like you can actually import the data you want from those two already. I don't think I'm going to work on this in the near future. If anyone gets interested in implementing this I will consider it but not for the moment. Thanks for your understanding.

durnezj commented 2 years ago

Hi, thanks for giving me a heads up! I still have not been able to find the time to invest into looking at a solution, and I'm not sure I will due to a busy period in my non-programming life. I have only been backing up my own last.fm scrobbles to my own database. I still need to couple them to the spotify equivalent of the song. As long as this repo stays up I can have the inspiration where to start if I find the time on a rainy sunday afternoon :wink: