How to play Youtube livestream on Chromecast with media_extractor?

this indeed looks like a problem with the live videos, i assume due to some issue with the yt-dl that is being used by the media_extractor for “video/youtube” media_type.

probably media_extractor implementation in home-assistant should support also the “is_live” option - see this info:

"is_live (boolean): Whether this video is a live stream or a fixed-length video"

Hi @goprojojo - If i understand the normal youtube link is working but livestream isn’t. I used your config above and tried to play a video but it doesn’t seem to work. I have added a media_player configuration too. Is the above config correct? Should we add a media_extractor section in config?

The above config should still work and you need to include media_extractor too. Try to replace it with a non-livestream url, for example: https://youtu.be/cHHLHGNpCSA

Hmm used it but looks like its still not working. Here’s my configuration. On executing this it gives me a “NotImplementedError”

media_player:

  • platform: braviatv
    host: 192.168.0.197
    name: living

media_extractor:
default_query: best

automation:
trigger:
- platform: time
at: ‘10:29:00’
action:
- service: media_extractor.play_media
data:
media_content_id: “https://youtu.be/cHHLHGNpCSA
media_content_type: video
entity_id:
- media_player.living

Try media_content_type: video/youtube

Nope. Unfortunately its the same error. Btw i am using a dockerized version of HA. So i dont know if its still supported.

Has anyone figured out live streaming? Non-live streams work fine.

Would be interested in casting a youtube live stream as well. Works fine with a regular video but as soon as I use a live stream URL it won’t load.

Any ideas how to solve this issue?

Indeed, would be nice to program a morning scene where the TV powers on and starts playing live news on the chromecast.

Has there been any update on this? I was also wondering if you could get around this by just having home assistant display an internal HTML page to the chromecast with just a simple iframe to the live video embedded?

Just chiming in, hoping for any solution here. I’d like to live stream the news when i get up.

I set up CATT in my HA container (non-persistent, but easy enough to restore when necessery)

Came across this thread today trying to live-stream lo-fi hip-hip girl and the local news. Turns out CATT does this out of the box :slight_smile: catt -d "My Room display" cast "https://www.youtube.com/watch?v=5qap5aO4i9A"

The only hassle is that I’m integrating this with HA via shell_command, and haven’t worked out how to pass service data to the command successfully. At this stage. I’m stuck using an individual command for each video, but that’s a pretty simple workaround.

1 Like

Subscribed also interested in live streams

1 Like

Hey all. I found a workaround I’m comfortable with at least, using the “YouTube app”:

service: media_player.play_media
target:
  entity_id: media_player.58pus8555_12_2
data:
  media_content_type: cast
  media_content_id: '
    {  
       "app_name": "youtube",
       "media_id": "Ek1-adoyE_0"
    }'

1 Like

What do you exactly mean with using the YouTube app? How would it look like in an automation within Home Assistant (using yaml)

I just tried the YAML I posted in the Developer Tools and it worked like a charm :slight_smile: I would expect the same YAML to work in an automation by just calling that service as an action?

Sorry for not being very clear; the “app”-part was just what I understood from the Home Assistant documentation where I found how to do this :slight_smile: It should not be important.

EDIT:

Here’s the documentation:

1 Like

My problem was very similar, I wanted to make an alarm clock with a YouTube live show. My problem was that the id changed every day when I started the stream. For this Google has its YouTube api. I created a new sensor to get the live id and call it from the automation. I leave the code below:

sensor:
  - platform: rest
    resource: https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={YOUR_CHANNEL_ID}&eventType=live&type=video&key={KEY_API}
    method: GET
    value_template: '{{ (value_json["items"][0].id.videoId | string) }}'
    name: "youtube"
    scan_interval: 2100        
action:
  - service: media_player.play_media
    data:
      media_content_type: cast
      media_content_id: " { \"app_name\": \"youtube\", \"media_id\": \"{{states.sensor.youtube.state}}\" }"
    target:
      entity_id: media_player.chromecast7018

Perdón por la traducción, cualquier cosa me escriben

I’m running into a new problem with casting live streams, it looks like the underlying pythin library casttube is not setting the correct Length header on one of its API calls resuling in the following erorr:

requests.exceptions.HTTPError: 411 Client Error: Length Required for url: https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch

Is anyone else seeing this or have a way around it?
I filed a bug here just in case: https://github.com/ur1katz/casttube/issues/13

The solution used to work for me, but now it no longer works. Not sure what changed. Would love to play live streams again

it’s not media extractor but it does work with live streams. using the Android TV Remote integration.

1 Like