YouTube Autoembeds for Live Streams

AI-generated summary

cogdog reported that Discourse’s YouTube onebox fails to auto-embed live stream URLs (e.g., https://www.youtube.com/live/...), though manually converting them to standard watch URLs (e.g., https://www.youtube.com/watch?v=...) works. cogdog reiterated the issue, noting the inconvenience for non-technical users. Falco confirmed the fix requires updating the YouTube onebox code to handle both URL formats, similar to a prior Twitch clips fix, and tagged it as pr-welcome. Arkshine submitted a PR to address this, and in post 5, demonstrated that the updated code successfully embeds live stream URLs, confirming the fix works as intended.

I run a few live events using Streamyard that go directly to YouTube. The stream becomes the recording, so the link is always good.

I notice that Discourse does not seem to embed the different URL format YouTube uses for this videos giving a generic OneBox e.g.,

https://www.youtube.com/live/eJemwqO0SDw e.g.

whereas by manually using the same ID in a standard YouTube URL does work in Discourse

https://www.youtube.com/watch?v=eJemwqO0SDw renders as expected

YouTube does not readily provide this form of a live stream video as a share link, so I end up manually re-writing the URLs. Seems like some pattern matching magic could manage this?

3 Likes

Anyone got a reply? This sure seems like a (like I would know) a search and replace for youtube links.

This happened again today:

This link fails to embed
https://www.youtube.com/live/N4vz0rlpXus?feature=shared&t=1355

But this does
https://www.youtube.com/watch?v=N4vz0rlpXus&t=1355

Yes, I can figure this out manually but the average user?

Anyone there?

2 Likes

This needs a change in the YouTube onebox code to accept both URLs interchangeably. Very similar to what I did in Twitch clips embed problem.

Tagging this as pr-welcome for now.

2 Likes

I made a PR:

https://github.com/discourse/discourse/pull/31673

7 Likes

Let’s try again https://www.youtube.com/live/eJemwqO0SDw:

https://www.youtube.com/live/N4vz0rlpXus?feature=shared&t=1355:


Looks good!

5 Likes