Love all songs in a playlist

Hello, it seems like there is no way to import liked songs from Spotify into LB
However, it’s pretty easy to create a playlist of all your liked songs and then import it into LB
Do you know if there is a way to love all the songs in a LB playlist ? This seems easier to implement and it could be a convenient workaround
Best,

2 Likes

Hi @sobornost !

Adding a way to import loved songs from Spotify is definitely on our list !
We have a ticket open for it (LB-713), but we haven’t gotten to it yet. I’ll see if we can bump it up in priority, the ticket has been open for a long time !

2 Likes

Hello !

Thank you for your prompt response, I noticed the ticket
I was just wondering if implementing a way to like an entire playlist could work as an easy to implement workaround
If it’s not don’t worry, I’ll wait (or try to play with the API)

2 Likes

Heres some quick Python code that can love/hate/unrate. Requires requests-ratelimiter

  1. Install Python from https://www.python.org/ (minimum version 3.11)
  2. In cmd run “python -m pip install requests-ratelimiter”
  3. Save the script to a file like script.py, put your token on line 5 and username on line 6
  4. Run “python script.py” in cmd
import json
from requests_ratelimiter import LimiterSession
rsession = LimiterSession(per_second=3)

listenbrainztoken = "YOUR-TOKEN-HERE"
r = rsession.get("https://api.listenbrainz.org/1/user/USERNAME/playlists", headers={"Authorization": "Token {0}".format(listenbrainztoken)})
playlists = json.loads(r.text)["playlists"]

for c, item in enumerate(playlists, start=1):
    print("{0}: {1} ({2})".format(str(c), item["playlist"]["title"], item["playlist"]["creator"]))
id = input("ID of playlist: ")
rate = input("Rate (1: loved, 0: unrated, -1: hated): ")

plmbid = playlists[int(id) - 1]["playlist"]["identifier"].split("/")[-1]
r = rsession.get("https://api.listenbrainz.org/1/playlist/" + plmbid, headers={"Authorization": "Token {0}".format(listenbrainztoken)})
mbpl = json.loads(r.text)
for item in mbpl["playlist"]["track"]:
    r = rsession.post("https://api.listenbrainz.org/1/feedback/recording-feedback", json = {"recording_mbid": item["identifier"][0].split("/")[-1], "score": int(rate)}, headers={"Authorization": "Token {0}".format(listenbrainztoken)})
3 Likes