I have an audio track in Plex that has a comma and an apostrophe in the title, as in Ode to Joy (Beethoven's Symphony No. 9, Op. 125)
. I think only the comma matters, but the apostrophe could be causing issues as well (although I was careful to use double-quotes for the string).
I would like to play this audio track to my Sonos speakers. To do so, I create a Plex API query as a javascript object, then stringify that object to create a content_id
string as follows:
plex://{"library_name": "Music", "track.title=": "Ode to Joy (Beethoven's Symphony No. 9, Op. 125)"}
As you can see, this query is meant to search for tracks that have the exact title Ode to Joy (Beethoven's Symphony No. 9, Op. 125)
. And I have exactly one track in my library with that title. But when I call media_player.play_media
with that string, I get an error message: “No music results in ‘Music’ for [my query].”
If instead I modify the query string to search for tracks with titles containing Ode to Joy (Beethoven's Symphony No. 9, Op. 125)
, I get multiple results—several tracks containing Ode to Joy (Beethoven's Symphony No. 9
, even though none of them contains the full title I searched for.
Based on these results, it looks to me like Plex is interpreting the comma in my query as a delimiter of some sort rather than as part of the string I am searching for. I have tried escaping the comma using a \
, but this did not affect my results. Has anyone encountered a similar problem, or does anyone have any suggestions for fixing it?
In case it matters, I am using a Node-RED flow. I have a function node that creates a javascript object, then creates the plex query string using str = "plex://" + JSON.stringify(obj)
. I then use that string as the content_id
value in a node that calls the play_media
service. Except for the issue I’ve described, this has worked correctly. And even when this issue occurs, I get a “no results” or “many results” error rather than a syntax error.