Youtube Music - Media Browser

Some files of my playlist don’t play and give an error…

[548431330224] string value is None for dictionary value @ data[‘media_content_id’]

hmm please open a ticket https://github.com/KoljaWindeler/ytube_music_player/issues
and add the debug output … thats the best way i can help. There are in fact >40 closed tickets already!

MPD

We’ve developed a fix for MPD (media_player) integration, for those interested:
https://github.com/KoljaWindeler/ytube_music_player#mpd-fix

Sonos

We also had the first successes with Sonos speakers
https://github.com/KoljaWindeler/ytube_music_player#sonos-support--proxy

And thanks a lot at @troy and Christian baart for the beer :slight_smile:
https://github.com/KoljaWindeler/ytube_music_player#support
Never thought that this would work and really appreciate your support :heart_eyes:

1 Like

Kolja, thank you very much for your time and effort to create, test this integration + troubleshoot users issues. It is working perfectly! HA needs more devs like you :smiley:

2 Likes

Thanks for your feedback, that means a lot to me :heart_eyes:

Never thought that troubleshooting would be such a big task. The integration is running flawlessly on my chromecast setup for weeks now, but the more players and setups we test the more strange stuff happens.

On the other hand each issue will steadily increase the capability of the player and I’m sure that together we can find solutions for almost everything.

So keep sending issues :wink:
Kolja

1 Like

Hey,that’s not an issue thanks. The scenario is when no media is playing, the door bell goes and then it starts playing the last playlist, I don’t want it to play that as it wasn’t playing when the doorbell went.
Cheers
Brent

1 Like

completely agree, without people like you non-devs like me would be dead in the water :smile: so thank you very much

2 Likes

Is it possible that ytube_music_player was still running and that you’ve only stopped your remote_player (the google_speaker)? If thats the case the ytube_music_player will wait on a transition from playing to idle which happens once the tts or doorbell is played and will play the next track as reaction.

The big question is how did you switch off of your google_speaker withouth turning off the ytube_music_player (switching off the google_speaker should also switch off the ytube_music_player) …

hmm if that error is persistant could you open an issue (https://github.com/KoljaWindeler/ytube_music_player/issues), enable debug messages (https://github.com/KoljaWindeler/ytube_music_player#debug-information) and copy from the log the time from ‘switching off music’ wait a few moments, play tts, ‘let ytube_music_player resume its old playback’ …

edit: I can easily reproduce your problem if I set the ytube_media_player into PAUSE -> play tts -> ytube_media_play will play the next track … could that be something?

@Nemesis24 Thanks for the Beer :heart_eyes:

2 Likes

well … still a bug … somehow … but I don’t see how to fix it

a) don’t react on a playing to idle transition when in pause mode
good: the next track won’t play in your scenario
bad: when the player is in “PAUSE” and the user click “UNPAUSE” it will send the ‘media_play’ command to the remote_player … but in your scenario the remote player can’t know what to play as it’s not longer in pause mode and already lost the URL of the track when it played the tts

b) always understand PAUSE as OFF
good: the next track won’t play in your scenario
bad: one can’t use pause anymore :slight_smile:

c) turn off the ytube_music_player when the state of the remote player changes from paused to playing without interaction of the ytube_music_player?
good: the next track won’t play in your scenario
bad: honest … maybe nothing … “something else took over so I’ll step back” … sound legit to me, don’t you thing

I guess the easiest would be to think of the “power off” button of the mini-media-player as “stop” button.

so that’s not it, tried different variants, will create an issue, thanks for the help!

Hey, that makes sense, the mini-media-player has Play/Pause not Play/Stop as standard.
yt_music_capture

tried the power off button but only by sending TTS command, kids and wife are in bed so don’t want to press the door bell, not worth my life :slight_smile:. I’ll give it a proper whirl and test tomorrow when I should be working
EDIT:
this seems to sort it
toggle_power: false
and

hide:
  play_stop: false
1 Like

great … but never the less … I’ve added this

to the code … will be part of the next release, once I’ve tested it a bit here … but seams to work fine

1 Like

Could you please have a look at the following error I’m getting when using the media browser to access my Albums. I can browse all the other categories.

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 1066, in websocket_browse_media
payload = await player.async_browse_media(media_content_type, media_content_id)
File "/config/custom_components/ytube_music_player/media_player.py", line 1367, in async_browse_media
response = await build_item_response(self.hass, self._api, payload)
File "/config/custom_components/ytube_music_player/browse_media.py", line 67, in build_item_response
media = await hass.async_add_executor_job(media_library.get_library_albums, BROWSER_LIMIT)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 140, in get_library_albums
get_continuations(results, 'gridContinuation', limit - len(albums), request_func,
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 86, in get_continuations
contents = get_continuation_contents(results, parse_func)
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 129, in get_continuation_contents
return parse_func(continuation[term])
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 138, in <lambda>
parse_func = lambda contents: parse_albums(contents, False)
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/library.py", line 58, in parse_albums
album['year'] = nav(data, SUBTITLE3)
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 167, in nav
raise err
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 161, in nav
root = root[k]
IndexError: list index out of range

That looks like a problem in the sub api … could you create a ticket at Issues · sigma67/ytmusicapi · GitHub

basically this is the first line of the real error

media = await hass.async_add_executor_job(media_library.get_library_albums, BROWSER_LIMIT)

That calls this: Reference — ytmusicapi 1.5.5.dev1+gc412d7c documentation

and that would be the error section

File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py”, line 140, in get_library_albums
get_continuations(results, ‘gridContinuation’, limit - len(albums), request_func,
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py”, line 86, in get_continuations
contents = get_continuation_contents(results, parse_func)
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py”, line 129, in get_continuation_contents
return parse_func(continuation[term])
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py”, line 138, in
parse_func = lambda contents: parse_albums(contents, False)
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/library.py”, line 58, in parse_albums
album[‘year’] = nav(data, SUBTITLE3)
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py”, line 167, in nav
raise err
File “/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py”, line 161, in nav
root = root[k]
IndexError: list index out of range

please mention me @KoljaWindeler in the ticket, so I’ll get notifications about it as well and can help with questions regarding the usage of the api.

Thanks JKW

Thanks. I’ve logged an issue here https://github.com/sigma67/ytmusicapi/issues/151

btw. i had the same problem yesterday. i ended up with deleting all albums in the album folder (i only had a few).
Opening the album folder in media browser, then creates a message “no albums in folder” or something like that as suspected.
After adding the albums again i didn’t get the “unknown error” message anymore.

@JKW:
I wonder if it might be possible to call Albums (inside users mediathek) from the album folder directly within an automation or in the lovelace frontend.
I know you already mentioned something regarding media_content_type: Album blowing the scope - nevertheless i think it would be a great feature. in my use case (Jukebox) i only want to call albums inside the mediathek and creating a single playlist for each is kind of annoying.

thx , regards

Hi, that’s already possible. Go to your media browser and start playing that album. Once it is running look at the attributes of the player. There will be a media type and media Id.

Note both values. Stop playback and call the play_media service with those two arguments … it should start playing the same album.

With that you can totally create a jukebox

Just to mention it here as well. @slipx06 created a ticket for the sub api.
He tracked down the issue together with sigma67 on GitHub. Fix is already implemented by sigma and will be available shortly for everyone here.

Perfect example for collaboration :+1:

2 Likes

New Release, mostly to update sub api

Hey @Ghafla82 this new release will use the new sub api 13.1. and thus support more tracks, please have a look. I can’t really test this as the most I have of one artist is 32 tracks … all are shown to me now

1 Like