OzymandiasTheGreat / mopidy-ytmusic

Mopidy extension for playling music/managing playlists in Youtube Music
Apache License 2.0
80 stars 28 forks source link

Stored track URIs are not re-useable #67

Open fatg3erman opened 2 years ago

fatg3erman commented 2 years ago

Don't know if this is just how Youtube Music works, but if I store a track URI (say from a search or a playlist) then try to add it to the tracklist at a later date (after restarting mopidy) I get 'Track is not playable'.

I'd like to be able to create local lists of tracks, since I can't use Mopidy to add things to "Liked Songs" or whatever on YTMusic.

fatg3erman commented 2 years ago

Seems that they work if the the extension has already cached them. For example if I add one of my 'Liked Songs' to the tracklist and copy the Uri, then restart Mopidy: Initially trying to add that Uri results in "directory or file not found", but if I browse my 'Liked Songs' and then try again I can add that Uri.

This is contrary to how other Mopidy backends work - eg Spotify used to allow you to add any Uri regardless.

bendschs commented 2 years ago

i think this is the same problem as described here:

https://github.com/OzymandiasTheGreat/mopidy-ytmusic/issues/24

hofaa commented 2 years ago

I think I have the same problem here: I have local playlists (m3u) with YTmusic URIs "ytmusic:track:MOabEBSxxxxx" When sending (over Iris) {"method":"core.tracklist.add","params":{"uris":["ytmusic:track:MOab.... I just get result = []

Also Iris does not show any track info, no cover etc.

If I find the album or a track via "Browse > YTMusic" or "Recently played" etc. the cover and track info appears, also in the playlist. But only for the songs that were displayed before in "Browse" etc.

Now it is also possible to add them to the tracklist

jaedb commented 2 years ago

@hofaa one thing you can try is reloading that particular playlist. In Iris use the context menu (right click on the thumbnail from a grid page, or the ... icon within the Playlist) and hit Refresh.

hofaa commented 2 years ago

@jaedb thank you for the hint. Unfortunatelly that does not change anything. Iris still only shows the URIs instead of track names after Refreshing and adding to the tracklist (playing) is not possible.

jaedb commented 2 years ago

Ah yes I understand now (I misread your comment, sorry). This would work if they belonged to a YT Music playlist, but not a local playlist.

It seems like Track URIs are bound by an authenticated session, so when the session ends (ie restarting, or running mopidy ytmusic reauth) the URIs are invalidated.

@OzymandiasTheGreat do you happen to know how ytmusicapi generates track URIs? Do they have any reference to the track ID in YT Music or are they localised to the ytmusicapi session?

fatg3erman commented 2 years ago

The track Uris are re-useable but somehow they're tied to a session and you need to do [insert something opaque and hacky] to use them if you restart, Mopidy-youtube does something with yt-dlp to make this work

hofaa commented 2 years ago

@jaedb and @fatg3erman is there something I can do, or does it need implemented in mopidy-ytmusic? I did not find any solution to actually get the track Uris reliably working again after a restart. Most of the time it helps though to find the corresponding track via "browse" on YTMusic, but that defeats the purpose of a playlist...

fatg3erman commented 2 years ago

@hofaa As far as I can tell there's nothing you can do, a track needs to have been browsed to make it playable.

jaedb commented 2 years ago

The issue with playlists is not apparent for YT-Music playlists (even your own), so perhaps the priority could be put on managing YT-Music playlists within Mopidy? This is already supported by ytmusicapi so we're not trying to swim against the current then.

fatg3erman commented 2 years ago

I think that already works. The problem is I don't want to store my playlists on YT Music because Mopidy supports multiple backends and I don't want to be tied to one source.

impliedchaos commented 2 years ago

Sorry, I've been really busy with work, and it's been a while since I looked at the backend. But I'm on holiday this weekend and will try to look at this. Getting better integration with RompЯ and other frontends would be fantastic.

fatg3erman commented 1 year ago

Hi @impliedchaos that's cool, we all have stuff to do :) I've been putting quite a lot of effort into RompR in an attempt to use YTMusic as a Spotify replacement. i have it working quite well here, with the modification I've sent you a PR for. This allows me to add any track URI provided I know the album URI. Looking up the album makes the track URI valid. Somehow :)

The ability to add any old track URI is the only missing piece. I looked briefly at how mopidy-youtube does it but I'm not really a python guy and I couldn't figure it out. I think it does something with yt-dlp to make the URI valid, but I'm not sure what it is.

impliedchaos commented 1 year ago

OK, the 0.3.8 release should sorta fix this. There is still an issue where it's damned near impossible to get the album from a track. Because google.

fatg3erman commented 1 year ago

Nice! I'll give it a spin as soon as I get a chance.

"Becasue google" 😂

hofaa commented 1 year ago

@impliedchaos you are the best, that works like a charm. Really makes a difference for me and the plugin complete! Thank you a lot!!

fatg3erman commented 1 year ago

That is working beautifully. Thanks @impliedchaos.

bendschs commented 1 year ago

works for me too now, thanks to all of you!