mopidy-tidal
mopidy-tidal copied to clipboard
Better track and album URIs
Track URIs are currently expressed in the format tidal:track:<artist-id>:<album-id>:<track-id>
, while albums are in the format tidal:album:<artist-id>:<album-id>
.
While this makes it efficient to lookup the parents of an object without performing an additional query, it also makes compatibility with "standard" Tidal URLs a mess.
I had previously set up some automation with Spotify that would allow me to share a track or album from the app/browser, send it via Tasker/Platypush, and it would then play or get added to the queue on one of my RPis. This was possible because mapping from https://open.spotify.com/track/<track-id>
to spotify:track:<track-id>
was straightforward, and one can easily leverage the MPD/JSONRPC interface to add stuff.
This isn't that easy with Tidal URIs, given their format. I would first need to perform a query to retrieve the track or the album, and then construct the URI with all the required parts.
We can probably maintain back-compatibility with the current format, but it should be quite straightforward to add a logic that, upon queue/playlist add, just pops the last item of the tidal:track:
URI and searches for that ID, instead of validating the URI format just to use the last token anyway.
I recommend still validating URIs, otherwise it just turns into a mess that can easily be abused. You’ll have to maintain compatibility with literally everything, which is an awful task.
Validation would indeed still be there, but we allow both the tidal:track:<artist>:<album>:<track>
and tidal:track:<track>
formats for tracks, and tidal:album:<artist>:<album>
and tidal:album:<album>
for albums.
In both the cases, after validation the logic would simply pop the last URI token, because it's all it needs to query the API.