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

Playlist Radio doesn't work #88

Closed
fr4nk2342 opened this issue Apr 19, 2021 · 19 comments
Closed

Playlist Radio doesn't work #88

fr4nk2342 opened this issue Apr 19, 2021 · 19 comments
Labels
bug Something isn't working

Comments

@fr4nk2342
Copy link

fr4nk2342 commented Apr 19, 2021

Describe the bug
For testing purposes I created a playlist with only one track and only this one track will be played repeatedly. But shouldn’t an automatic playlist with similar tracks be played? At least that’s how it works on the YTM website.

Version
20210414

To Reproduce
Steps to reproduce the behavior:

  1. on the ytube website: create a playlist with only one entry
  2. in homeassistant: use media_browser → playlists → start playlist
  3. open development settings: display attributes of the media_player.ytube_music_player
  4. copy playlist id from ‘_media_id’ attribute
  5. call media_player.play_media with the same content_id from 4
    media_content_type: channel,
    entity_id: media_player.tube_music_player

YAML:

service: media_player.play_media
data:
  media_content_id: PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH
  media_content_type: channel
target:
  entity_id: media_player.ytube_music_player

or:

  1. Select Playlist in dropdown
  2. Source: Playlist Radio
  3. Select Speaker
  4. Start

Additional context

2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] play_media, media_type: channel, media_id: PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_prepare_play
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_check_api
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_update_remote_player(/media_player.google_group_heimgruppe)
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] END async_update_remote_player
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_media_stop
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - async_media_stop -> media_player.google_group_heimgruppe
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_get_cipher
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:27 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: playing -> idle
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] get_playlist(playlistId=PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH) ... get_watch_playlist(videoId=j2rdAw82Uvk)
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] _tracks_to_attribute
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] END _tracks_to_attribute
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] _play
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_get_track
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - Playing track nr 0 / 1
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_get_url
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_check_api
2021-04-19 09:54:28 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - try to find URL on our own
2021-04-19 09:54:29 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - self decoded URL via cipher
2021-04-19 09:54:29 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:29 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: idle -> idle
2021-04-19 09:54:29 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:29 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: idle -> playing
2021-04-19 09:54:30 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:30 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: playing -> playing
2021-04-19 09:54:30 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:30 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: playing -> playing
2021-04-19 09:54:31 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
2021-04-19 09:54:31 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] media_player.google_group_heimgruppe: playing -> playing
2021-04-19 09:54:44 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_sync_player
@fr4nk2342 fr4nk2342 added the bug Something isn't working label Apr 19, 2021
@KoljaWindeler
Copy link
Owner

hmm look legit to me .. does it work on the website?
get_playlist(playlistId=PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH)
pulls the correct playlist 'entries' .. the code tries to get a watch playlist based on that one video id
get_watch_playlist(videoId=j2rdAw82Uvk)
not sure why that only generates 1 track from the playlist

@fr4nk2342
Copy link
Author

Yes, it works on the YTM-Website

  1. open Playlist
  2. click three dots
  3. Radio starten

also tried to reload playlists, with no luck:

service: ytube_music_player.call_method
data:
  entity_id: media_player.ytube_music_player
  command: reload_dropdowns

@KoljaWindeler
Copy link
Owner

funny, i can open that track (aura - avoure) and create a playlist, with only that one track.
After that I do the exact same thing that you've done .. start a radio .. works flawless .. same output that you have, but loads 25 tracks .. could you set you playlist to "public" ?

@fr4nk2342
Copy link
Author

Made the playlist public:
https://music.youtube.com/playlist?list=PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH

same result

@KoljaWindeler
Copy link
Owner

2021-04-19T09:50:57.466889278Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] get_playlist(playlistId=PLqekoEAOX6ZF6oJ8d3fzk3WpsbCz2M2fH) ... get_watch_playlist(videoId=j2rdAw82Uvk)
2021-04-19T09:50:57.478635612Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - shuffle new tracklist
2021-04-19T09:50:57.495266656Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] _tracks_to_attribute
2021-04-19T09:50:57.496229007Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] END _tracks_to_attribute
2021-04-19T09:50:57.502857707Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] _play
2021-04-19T09:50:57.503960004Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] async_get_track
2021-04-19T09:50:57.504529607Z 2021-04-19 11:50:57 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] - Playing track nr 0 / 25

ok ... so that's really strange, right?

@KoljaWindeler
Copy link
Owner

pinging @sigma67
Hey Sigma, any idea why the same code on two different accounts / machines generates either only 1 track or 25 tracks after calling get_watch_playlist(videoId=j2rdAw82Uvk)
Thanks, JKW

@sigma67
Copy link

sigma67 commented Apr 19, 2021

You know that you can use a playlistId as input for get_watch_playlist? Not sure why you're using a videoId here, maybe I'm missing something.

The correct way to shuffle a playlist is get_watch_playlist_shuffle(playlistId), if you want radio it's get_watch_playlist("RDAM" + playlistId)

@KoljaWindeler
Copy link
Owner

Jep, I know. I had an issue a longer time ago .. that's why I'm currently picking one song and create a watch list based on that one song.
Works flawlessly .. usually ;)

@sigma67
Copy link

sigma67 commented Apr 19, 2021

What issue did you have? It should work fine I think.

I get a watch playlist with a single track (as you mentioned) only if I use get_watch_playlist(playlistId=playlistId), with the single-track playlist you mentioned above. Note that I didn't add the RDAM part, which would produce the radio.

@KoljaWindeler
Copy link
Owner

why is get_watch_playlist(videoId=j2rdAw82Uvk) producing a 25 tracks long playlist for me and a 1 track long list for @fr4nk2342

thats the question in short

@KoljaWindeler
Copy link
Owner

and... although off topic, but what am I doing wrong here (thought I give the RDAM part a try):

2021-04-19T11:31:51.084804449Z 2021-04-19 13:31:51 DEBUG (MainThread) [custom_components.ytube_music_player.media_player] get_watch_playlist(playlistId=RDAMPLZvjm51R8SGuWhMtfSu-A17Kp3jZfg6pg)

...

[custom_components.ytube_music_player.media_player] Traceback (most recent call last):
2021-04-19T11:31:51.096092717Z   File "/config/custom_components/ytube_music_player/media_player.py", line 1148, in async_play_media
2021-04-19T11:31:51.096102962Z     self._tracks = await self.hass.async_add_executor_job(self._api.get_watch_playlist,"RDAM"+str(media_id))
2021-04-19T11:31:51.096110210Z   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
2021-04-19T11:31:51.096117155Z     result = self.fn(*self.args, **self.kwargs)
2021-04-19T11:31:51.096134429Z   File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/watch.py", line 78, in get_watch_playlist
2021-04-19T11:31:51.096145883Z     results = nav(watchNextRenderer,
2021-04-19T11:31:51.096152610Z   File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 146, in nav
2021-04-19T11:31:51.096159044Z     raise err
2021-04-19T11:31:51.096164940Z   File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 140, in nav
2021-04-19T11:31:51.096171865Z     root = root[k]
2021-04-19T11:31:51.096178122Z KeyError: 'content'

@sigma67
Copy link

sigma67 commented Apr 19, 2021

It doesn't work with videoIds, if that's what you're trying?

I have no idea what could cause only a single track to be returned for get_watch_playlist with videoId parameter. I always get more than that, only if I use the playlistId I get a single track

@KoljaWindeler
Copy link
Owner

KoljaWindeler commented Apr 20, 2021

ah ok .. because the first parameter is actually the videoId and not the Playlist .. ok got it working .. this might also fix it for @fr4nk2342

but is still fails with the 'liked music' playlist .. So calling get_watch_playlist(playlistId="RDAMLM") results in the same error shown above. Is there any workaround? get_playlist("LM") followed by picking a random track and lastly generating the radio via get_watch_playlist(videoId="RDAM"+videoId_of_random_picked_song) works .. but is a bit chunky .,

I have no idea what could cause only a single track to be returned for get_watch_playlist with videoId parameter. I always get more than that, only if I use the playlistId I get a single track

yep, same here .. the code (as of now) would take one videoId and pass that to get_watch_playlist .. works fine .. for me

@KoljaWindeler
Copy link
Owner

KoljaWindeler commented Apr 20, 2021

ah .. found it myself .. for whatever reason the id for LM is RDAMPLLM not RDAMLM
@fr4nk2342 I'll release a new version with the modified Radio generation soon, please reopen this if the behavior is still the same

@sigma67
Copy link

sigma67 commented Apr 20, 2021

yep, same here .. the code (as of now) would take one videoId and pass that to get_watch_playlist .. works fine .. for me

That works but I'm pretty sure it's not the same thing semantically. Would be pretty disappointing if that's actually what's happening (since a playlist radio should be based on the entire playlist not just one track)

@fr4nk2342
Copy link
Author

I just want to confirm that everything works as expected. Thank you.

@sigma67
Copy link

sigma67 commented Apr 20, 2021

Sorry for not being specific enough with the RDAM part, as you noticed it's RDAMPL. It's also documented in the FAQ: https://ytmusicapi.readthedocs.io/en/latest/faq.html#how-can-i-get-the-radio-playlist-for-a-song-video-playlist-or-album

@KoljaWindeler
Copy link
Owner

KoljaWindeler commented Apr 20, 2021

Jep,

actually all playlist already start with "PL" but LM ... So I've added a little "if" that adds the PL to the LM ;)

non-sense ... you're right .. RDAMPL!

@ragaimeena
Copy link

I am haing the same issue. Everything is up to date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants