Closed Sleinous closed 4 months ago
Hey there @joostlek, mind taking a look at this issue as it has been labeled with an integration (media_extractor
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
media_extractor documentation media_extractor source (message by IssueLinks)
I've got the same issue
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment π This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue still exists
EnvoyΓ© Γ partir de Outlook pour Androidhttps://aka.ms/AAb9ysg
From: issue-triage-workflows[bot] @.> Sent: Wednesday, March 13, 2024 11:08:15 PM To: home-assistant/core @.> Cc: Sleinous @.>; Author @.> Subject: Re: [home-assistant/core] Media Extractor integration doesn't play YouTube audio to Sonos (Issue #103984)
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment π This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
β Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/103984#issuecomment-1995970864, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIAUWR7Z3QAW4F4ID3O5YRDYYDE47AVCNFSM6AAAAAA7LOSGA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVHE3TAOBWGQ. You are receiving this because you authored the thread.Message ID: @.***>
For some reason youtubedl ignores that best=mp3 from the looks of it, not sure why that happens
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment π This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
@joostlek, I think this should be re-opened. media_extractor.extract_media_url
seems to ignore all format_query
strings, which seems like a potential cause of this issue.
Using the example from media_extractor.play_media
(https://soundcloud.com/bruttoband/brutto-11), when manually checking formats with youtube-dl on my computer (2021.12.17), I get the following:
$ youtube-dl -F https://soundcloud.com/bruttoband/brutto-11
[soundcloud] bruttoband/brutto-11: Downloading info JSON
[soundcloud] 223644255: Downloading JSON metadata
[soundcloud] 223644255: Downloading JSON metadata
[soundcloud] 223644255: Downloading JSON metadata
[info] Available formats for 223644255:
format code extension resolution note
hls_opus_64 opus audio only audio@ 64k
hls_mp3_128 mp3 audio only audio@128k
http_mp3_128 mp3 audio only audio@128k (best)
In this case, the one labeled (best) is indeed the ideal format, as the http stream simply returns an mp3 file (whereas the hls returns an m3u). And by default, it is the url which is returned β :
$ youtube-dl -g https://soundcloud.com/bruttoband/brutto-11
https://cf-media.sndcdn.com/50remGX1OqRY.128.mp3?Policy=<... rest of url>
The same thing is returned when I pass in any of the following: best
, bestaudio
, best[ext=mp3]
, bestaudio[ext=mp3]
, http_mp3_128
Ex. β
:
youtube-dl -f http_mp3_128 -g https://soundcloud.com/bruttoband/brutto-11
https://cf-media.sndcdn.com/50remGX1OqRY.128.mp3?Policy=<... rest of url>
By contrast, if I instead give hls_mp3_128
for the format, I receive an m3u link:
youtube-dl -f hls_mp3_128 -g https://soundcloud.com/bruttoband/brutto-11
https://cf-hls-media.sndcdn.com/playlist/50remGX1OqRY.128.mp3/playlist.m3u8?Policy=<... rest of url>
But when I use media_extractor.extract_media_url
I always get the same thing back:
service: media_extractor.extract_media_url
data:
url: https://soundcloud.com/bruttoband/brutto-11
format_query: bestaudio[ext=mp3]
Returns β:
url: >-
https://cf-hls-opus-media.sndcdn.com/playlist/50remGX1OqRY.64.opus/playlist.m3u8?Policy=<... rest of url>
I can pass in anything and get this response: best
, bestaudio
, best[ext=mp3]
, bestaudio[ext=mp3]
, http_mp3_128
, hls_mp3_128
, garbage
, etc
. It makes no difference, it is always returning the hls_opus_64
format (the first available format in the list).
Edit: after typing this up, I noticed that there was a switch to yt-dlp instead of youtube-dl last year. I retried my queries again with yt-dlp (2024.05.27), and most (best[ext=mp3]
, bestaudio[ext=mp3]
, http_mp3_128
, hls_mp3_128
) returned the same things as youtube-dl, except best
, bestaudio
, and the default (no -f given), which returned the hls_opus_64
format.
With yt-dlp, the format list is in a different order:
$ yt-dlp -F https://soundcloud.com/bruttoband/brutto-11
[soundcloud] Extracting URL: https://soundcloud.com/bruttoband/brutto-11
[soundcloud] bruttoband/brutto-11: Downloading info JSON
[soundcloud] 223644255: Downloading hls_mp3 format info JSON
[soundcloud] 223644255: Downloading http_mp3 format info JSON
[soundcloud] 223644255: Downloading hls_opus format info JSON
[info] Available formats for 223644255:
ID EXT RESOLUTION β FILESIZE TBR PROTO β VCODEC ACODEC ABR
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
hls_mp3_128 mp3 audio only β ~3.50MiB 128k m3u8 β audio only mp3 128k
http_mp3_128 mp3 audio only β ~3.50MiB 128k http β audio only mp3 128k
hls_opus_64 opus audio only β ~1.75MiB 64k m3u8 β audio only opus 64k
This refutes my point about it picking the first format. But it seems like yt-dlp is always being called with the default format from media_extractor.extract_media_url
, regardless of format_query
.
Hello,
I'm encountering exactly the same issue as mentioned above. I'm trying to broadcast the audio from a youtube video to my Sonos speaker, but it's not working. I too tried to check the output of media_extractor.extract_media_url , and it shows that yt-dlp doesn't seem to care at all about the format_query, which I guess might be the cause of the problem.
@joostlek , should I open a new issue ? Or could this one be reopened ?
Thanks !
The problem
A previous issue was raised and fixed by @joostlek regarding playing youtube audio from media_extractor It seems i'm experiencing a similar issue whereby my Sonos device will not play audio from youtube links. If my understanding is correct media_extractor should search for audio in youtube links, however, despite modifying media_extractor configuration.yaml it still tries to play the video mp4 url to sonos (which obviously fails given it's an audio device) -->
Error calling SonosMediaPlayerEntity._play_media on media_player.sonos_chambre: UPnP Error 714 received: Illegal MIME-Type
I tried the following configuration.yaml for media_extractor:
also tried :
bestaudio[ext=mp3]
bestaudio[ext=m4a]
bestaudio[ext=ogg]
Here's the error log output Service Call :
Error executing service: <ServiceCall media_player.play_media (c:01HF7SPG1HCYCF2CMBD0JQDNBD): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gee.googlevideo.com/videoplayback?expire=1700016739&ei=A95TZZqGJ6u9xN8Pv_WY-AU&ip=2a01%3Ae0a%3Ab51%3A1881%3A%3A758&id=o-ANDoVZOYQPRD9eFecMeZZYSQ5dis8oJbme__SLHEfPRv&itag=22&source=youtube&requiressl=yes&mh=4N&mm=31%2C29&mn=sn-4gxx-25gee%2Csn-4gxx-25gy&ms=au%2Crdu&mv=m&mvi=3&nh=EAE%2CEAE&pl=49&gcr=fr&initcwndbps=837500&spc=UWF9f3ksna66yPJfg5R5tlQkMj_Jasg&vprv=1&svpuc=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=280.566&lmt=1679738956453811&mt=1699994724&fvip=3&fexp=24007246&beids=24350018&c=ANDROID&txp=4532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=ANLwegAwRgIhAKJX4v021cEPTwDENpC0rKfpWwXIZGEZlUDXYDVsnOWPAiEAuJFJ5OMnGaiJP9TrD4knIyXWfw0kEWTqXQEBLtf_bto%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cnh%2Cpl%2Cinitcwndbps&lsig=AM8Gb2swQwIgCJOm_XExUAvulkk8qa7H3GcUVI6lGxskqgAcfyByPlkCH3_DH6lyvN1F2bfTQ6C73t_EA_JpQV8SSNELSHQ7xw0%3D> Error executing service: <ServiceCall media_player.play_media (c:01HF7SZ48YHD6GSMZCZRAQQ30E): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gy.googlevideo.com/videoplayback?
more specifically we can see media_extractor trying to pass mp4 video through to Sonos ;
&mime=video%2Fmp4
this results in a MIME Type error.Here's my service payload:
If anyone's able to shed som elight on this it'd be much appreciated, thanks!! Sleinous
Note: Only music & playlist seem to work, MUSIC, PLAYLIST, audio/youtube etc don't work and aren't accepted by Sonos.
What version of Home Assistant Core has the issue?
core-2023.11.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
media extractor
Link to integration documentation on our website
https://www.home-assistant.io/integrations/media_extractor/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response