Is it possible to export Listens as a text file?

I’d like to have my recent Listens exported as a plain text file, or have Listenbrainz display my recent Listens with plain formatting, so I can just select and copy in to an email. Just a simple list with Song Name, Album, and Artist, in the order they were played (or reversed, it doesn’t matter).

Ideally, I’d like to be able to filter the list by day (or whatever range I input) – I think that’s already built in to the current Listens display ( at https://listenbrainz.org/user// )

Does such a tool already exist?

Thanks!

Hi!

We provide an api and also an option to export listens from profile page but both give the output in json format. For example: https://api.listenbrainz.org/1/user/loosenut/listens. I think you are looking for something like a csv format instead. The nice thing is that there exist online to convert between the two. For example: JSON To CSV Converter (not an endorsement just a random site I found by quick google search). You can open the api url, copy its results paste into this website and get the data in the format you want.

Regarding filter by day, you can supply min_ts and max_ts to that url. To get the right values for those choose the day you want listens for in the calendar or browse using older and newer buttons. When on the desired page, note its url.

Let’s say the url is https://listenbrainz.org/user/loosenut/?max_ts=1663865505
Then, you need to open https:/api.listenbrainz.org/1/user/loosenut/listens?max_ts=1663865505

If the url has min_ts then api url should also be written with min_ts. I hope this makes some sense and is helpful. Let me know if you have any doubts or queries.

1 Like

Thank you so much! I made a quick Google Collab python script that automates the process. If anybody wants the code, here it is:

import requests, json
username = "loosenut" #insert your username here
maxts = "1663865505" #time to look back in milliseconds

url = "https://api.listenbrainz.org/1/user/" + username + "/listens?max_ts=" + maxts
urldata = requests.get(url)  # max_ts is the timeframe it looks back on
text = urldata.text
data = json.loads(text)

for i in data['payload']['listens']:
  song = i['track_metadata']
  print(song['track_name'], "by", song['artist_name'], " [", song['release_name'], "]" )

Awesome! (sorry I had not asked earlier if you knew some scripting/programming otherwise would have suggested that :))