[BUG] youtube link parsing

YouTube links are not always parsed correctly and sometimes you get broken embeds.

This happens because the video ID is not properly parsed from the link.
I created a regex that extracts video IDs of all currently known youtube links:


It can be evaluated along with many examples on regexr.com.
The examples are taken from here.


Did hear it is fixed already for next beta 77


Regarding clips (as I was told they won’t work):

An alternative way to implement this would be to use the lovely OGP.
When requesting any YouTube video (be it a video, short, clip, or whatever) the header contains some metadata.
E.g. requesting https://www.youtube.com/clip/Ugkxz1ndWCIBhf-3q5bLyLqxK-H4GkkD0DVV results in a webpage containing the following meta tag:

<meta property="og:video:url" content="https://www.youtube.com/embed/nRh3lgB8KxI?clip=Ugkxz1ndWCIBhf-3q5bLyLqxK-H4GkkD0DVV&amp;clipt=EIj8BRjgsgY">

When YouTube embeds are created there is a connection to the YouTube servers anyways so there should be no security concern loading the embeds this way on the receiver side (unlike with other OGP embeds).

In the future when general OGP embeds are created on the sender side this could also be replaced by that.