I can retrieve the star rating in the userRating attribute at GET /library/metadata/<ratingKey>
Just wondering if there is a way to set the rating to a different value. Seems like there must be (PlexAmp does it) but I haven’t been able to find an example.
It can be done via PUT /:/rate?identifier=com.plexapp.plugins.library&key=<ratingKey>&rating=<rating>
In general, if you’re looking for the web API endpoint, seeing how Python-PlexAPI does it is very useful (e.g. for rating items, see plexapi.mixins — Python PlexAPI documentation). You can also do the action in the web app with your browser dev tools open and see what requests the app makes to your server.
I have a related question… I want to find a way to issue a rating for the track that’s currently playing. I guess ratingKey is a track identifier, is there a way to specify Now Playing?
I want to put rating buttons on my Stream Deck, or even create a home automation gadget on an esp32 with rating buttons. But this will only work if there is a way that I can easily target the track that’s playing for my account, right now.
I have realized that I am never going to use ratings until I can have a rating button that has zero speed bumps – I am not going to stop what I am doing in a window and bring up Plexamp and make sure it is on the right screen and then carefully drag my mouse to issue the correct rating. But if I have buttons that are always visible in my environment, and just work without any extra steps, I think I would issue a lot of ratings.
You would have to specifiy not only the account, but also the specific device. Because you can easily play different music simultaneously on different plex clients, by using all the same plex account.
And if you have to determine all of that, you migth as well simply determine the guid of the track.
I can certainly limit things to a specific user and specific client, like my account using Plexamp on a specific computer. Given that, is there any way to issue a rating with one remote command, without the extra steps of looking up the current track ID?
Perhaps a new method could be built into the server or just Plexamp which would allow an http request to issue the rating change for the “now playing” track, given the account and client ID if required by the context.
Tagging @elan since he is usually up for a Plexamp chat.
The dream, a simple http request behind each button:
Assuming you usually use Plexamp on the PC your Stream Deck is connected to, have you played around with Settings > Experience > Desktop Integration > Global Keyboard Shortcuts > Track Rating Shortcuts? The shortcuts are truly global (it doesn’t matter what window has focus), so if you can map your stream deck buttons to specific keyboard inputs that match what you have set in Plexamp, you might not have to mess around with the API at all.
Until we have a public API documentation, I couldn’t tell with certainty.
However, since Plex can always play more than one media item concurrently, I deem it unlikely that there is a simple “rate the currently playing track” command.
Out of curiosity, is there a reason for wanting a single request beyond making it easier to implement? From what I can tell stream decks (and presumably an esp32) can assign arbitrary scripts to a button, so a single request doesn’t seem strictly necessary. If you come across a scenario where Plexamp’s shortcut keys aren’t enough, it should be relatively straightforward to make a small script that grabs /status/sessions to get the actively playing items, filters it to the right username/client, then calls /:/rate with that info.
The Stream Deck can invoke any process you want, yeah, it’s quite flexible. (It’s actually one of the best computer gadgets I have ever used, love it!)
One command fielded by Plex itself is preferred just to make it easier to implement. I am a crummy programmer. If I have to write software to get it done, it’s probably not going to happen, or be pretty if it does happen.
Regardless, it is clear that to make a system that works automagically, hooking up some logic will be required. Maybe I will vibe code it, LOL.
But for now, I think I can get by with Plexamp’s shortcuts now that I know they exist.