Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where can I find the documentation to write a new libre.fm client? #41

Open
jcorporation opened this issue Oct 3, 2024 · 27 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@jcorporation
Copy link

I want to write I client for myMPD, but I have found no API documentation for libre.fm.

@mattl
Copy link
Member

mattl commented Oct 3, 2024

There is none. It would be useful to add some to the wiki. Mostly you'll just want to write a client for Last.fm and change the endpoints.

@jcorporation
Copy link
Author

Is libre.fm compatible with the v2 API or is only the v1 API for Last.fm implemented?

@mattl
Copy link
Member

mattl commented Oct 3, 2024 via email

@jcorporation
Copy link
Author

What API would you recommend for a new client?

@mattl
Copy link
Member

mattl commented Oct 3, 2024 via email

@jcorporation
Copy link
Author

Is it better to wait for the new authentication system to be implemented? I do not want implement a client for an old or obsolete api.

@mattl
Copy link
Member

mattl commented Oct 3, 2024 via email

@jcorporation
Copy link
Author

What are the correct scrobling endpoints? Is turtle.libre.fm correct? Must I append any path for the api version?

@mattl
Copy link
Member

mattl commented Oct 3, 2024

Treat turtle.libre.fm as post.audioscrobbler.com in any documentation you have.

@jcorporation
Copy link
Author

Ok, thanks. For last.fm v2 API there are an API Key and an API Secret besides the username and password. How can I generate this tuple for libre.fm?

@mattl
Copy link
Member

mattl commented Oct 3, 2024 via email

@jcorporation
Copy link
Author

My last.fm client uses https://ws.audioscrobbler.com/2.0/ as endpoint. I think I must write a complete new client that uses this documentation: https://www.last.fm/de/api/submissions

@mattl
Copy link
Member

mattl commented Oct 3, 2024 via email

@jcorporation
Copy link
Author

I got a 404 response sending the first POST request to "https://turtle.libre.fm/2.0/?format=json"

payload: "password=redacted&username=jcorporation&method=auth.getMobileSession"

@mattl
Copy link
Member

mattl commented Oct 3, 2024

Yes, send it to https://libre.fm/2.0/

@jcorporation
Copy link
Author

Sorry, I missed the change of the host. Now I get a "Invalid parameters - Your request is missing a required parameter".
POST request is send to: https://libre.fm/2.0/?format=json
With payload: api_sig=6c8f2ac19b54c84c0f9691d20e2f4d1f&method=auth.getMobileSession&username=jcorporation&api_key=notusedbylibre.fm&password=redacted

This should fetch the session key as described in the last.fm documentation and this works for last.fm.

Any hint?

@mattl
Copy link
Member

mattl commented Oct 4, 2024

See if you can get https://launchpad.net/ubuntu/+source/zomg/0.8.1-2 working locally. That should just work and I think you’ll be able to see how it works.

@jcorporation
Copy link
Author

jcorporation commented Oct 4, 2024

This client implements the old scrobbling API, but I will try.

I reviewed it's code and re-implemented it in Lua. My code works successfully with last.fm, but not with libre.fm.
I can get the session id, but submitting a scrobble results in a BADSESSION error.

I only changed username/password and the handshake url from http://post.audioscrobbler.com/ to http://turtle.libre.fm/.

I read the uri's for submissions and now playing from the first successfull handshake response.

@jcorporation
Copy link
Author

I am unable to find the reason why my client does not work with libre.fm but with last.fm. I installed mpdscribble and it works successfully with my account on libre.fm.

I captured the network traffic to find differences between my implementation and that from mpdscribble, but for me the requests are looking in both cases correct. Any further hint?

mpdscribble - successfull

> GET /?hs=true&p=1.2&c=mdc&v=0.25&u=jcorporation&t=1728212467&a=redacted HTTP/1.1
> Host: turtle.libre.fm
< OK
< 480b5048b6f8a5b0ad66eed0de34d7b0
< http://turtle.libre.fm/nowplaying/1.2/
< http://turtle.libre.fm/submissions/1.2/

> POST /nowplaying/1.2/ HTTP/1.1
> Host: turtle.libre.fm
> s=480b5048b6f8a5b0ad66eed0de34d7b0&a=Billy%20Idol&t=Flesh%20for%20Fantasy%20%28session%20take%29&b=Rebel%20Yell&l=309&n=13&m=d39ae2b3-110b-40fc-a83e-f232c5d65213
< OK

mympd client - not working

> GET /?v=1.0&hs=true&p=1.2&u=jcorporation&a=redacted&t=1728212717&c=myMPD HTTP/1.1
> Host: turtle.libre.fm
< OK
< 8e4992fe60256941f044d4c5d29a800b
< http://turtle.libre.fm/nowplaying/1.2/
< http://turtle.libre.fm/submissions/1.2/

> POST /nowplaying/1.2/ HTTP/1.1
> Host: turtle.libre.fm
> n=3&m=&l=298&b=Rebel%20Yell&a=Billy%20Idol&t=Eyes%20Without%20a%20Face&s=8e4992fe60256941f044d4c5d29a800b
< BADSESSION

@mattl
Copy link
Member

mattl commented Oct 6, 2024

Is your client successfully able to login before you make those submissions?

@mattl mattl added the documentation Improvements or additions to documentation label Oct 6, 2024
@jcorporation
Copy link
Author

You mean the handshake? Yes, I get a OK and a session id that looks good for me.

@mattl
Copy link
Member

mattl commented Oct 7, 2024

Can you write up some details on how we might test this code of yours?

@jcorporation
Copy link
Author

jcorporation commented Oct 8, 2024

  1. You need a working MPD installation
  2. Install myMPD 18.1.0 (not yet released, it is in the devel branch): https://jcorporation.github.io/myMPD/010-installation/. If you do not want to compile it, you can use the container image: https://github.com/jcorporation/myMPD/pkgs/container/mympd%2Fmympd-devel
  3. Create a new script: https://github.com/jcorporation/mympd-scripts/tree/librefm/audioscrobbler
    a) Copy the content of audioscrobbler.lua into the script textarea
    b) Add a script argument named trigger
  4. Add the variables as described in 3
  5. Scrobbly manually by playing a song and run the script manually - use scrobble as the argument

Screenshot from 2024-10-08 20-04-21

image

Screenshot from 2024-10-08 20-05-10

@FoxxMD
Copy link

FoxxMD commented Oct 25, 2024

I would also like to implement a librefm client for my scrobbling app, multi-scrobbler, which will enable scrobbling from many sources to librefm -- but I need (want) to implement the lastfm 2.0 protocol since I already have a Lastfm client implemented for this. However, I do not see anywhere on my profile page to get or create an API key. How can I get this? Or is it just a matter of running through the auth flow with a callback url and fake API key and getting a token back?

@thrzl
Copy link

thrzl commented Oct 26, 2024

I'm currently attempting to make a fork of the rustfm-scrobble crate that would instead scrobble to Libre.fm (using the 2.0 API). auth.getMobileSession did not work for me either, while I was able to get the Web authentication (manually getting a token from https://libre.fm/api/auth/?api_key=\<key>&cb=http://localhost:8000/) to work. I believe there may just be an issue with the mobile session method at the moment. I plan to try the desktop authentication later.

@mattl
Copy link
Member

mattl commented Oct 26, 2024

So we may not fully implement the API so we may need some contributions to make that work.

@thrzl
Copy link

thrzl commented Oct 27, 2024

I don’t presently know PHP, but I’d be open to taking a look at it.

I’d at the very least be willing to write docs for what is there so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants