stackernews / stacker.news

Internet communities that pay you Bitcoin
https://stacker.news
MIT License
439 stars 113 forks source link

YouTube "clip" embed #879

Open huumn opened 9 months ago

huumn commented 9 months ago

We embed youtube videos but not clips which are becoming more common. example: https://stacker.news/items/438611

TheMhv commented 8 months ago

This is harder than it seems.

The path /clip/clipId is not compatible with embed. To make it work as an embed, you must have 2 parameters that are not shared in this path, videoId (which is the default embed parameter) and clipt (some video time parameter, a hash that does not exist as a standard )

But there is a "solution", you can make a request directly to the link and get the embed link that is shown by the metadata tags og:video:url, og:video:secure_url or twitter:player.

The problem is that Youtube has a CORS policy that does not accept requests from other servers, so it is not possible to make a request directly through the code, the request would have to go through a reverse proxy server that bypasses cors

https://stackoverflow.com/questions/74697206/what-format-is-the-data-in-the-clipt-parameter https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues/5344