This is here because it doesn't just want a direct link to the m3u8 file. So we make an extremely basic site that just includes the video, and maybe the alt text if i care enough
(c *fiber.Ctx)
| 196 | // This is here because it doesn't just want a direct link to the m3u8 file. |
| 197 | // So we make an extremely basic site that just includes the video, and maybe the alt text if i care enough |
| 198 | func CDNVideoProxy(c *fiber.Ctx) error { |
| 199 | video_url := "https://video.bsky.app/watch/" + c.Params("did") + "/" + c.Params("link") + "/720p/video.m3u8" // 720p on an iphone 2g oh god |
| 200 | thumbnail_url := "https://video.cdn.bsky.app/hls/" + c.Params("did") + "/" + c.Params("link") + "/thumbnail.jpg" |
| 201 | |
| 202 | c.Context().SetContentType("text/html") |
| 203 | |
| 204 | c.Set("Cache-Control", "public, max-age=604800") |
| 205 | |
| 206 | return c.SendString(fmt.Sprintf(videoTemplate, thumbnail_url, video_url)) |
| 207 | } |
| 208 | |
| 209 | var videoTemplate = `<meta content="width=device-width,initial-scale=1"name=viewport><title>Bluesky Video</title><style>*{margin:0;padding:0;width:100%%;height:100%%}</style><body><script src=https://cdn.jsdelivr.net/npm/hls.js@1></script><video autoplay="autoplay" controls id=v poster=%s src=%s></video><script>var v=document.getElementById("v");if(v.canPlayType("application/vnd.apple.mpegurl"));else if(Hls.isSupported()){var h=new Hls;h.loadSource(v.src),h.attachMedia(v)}</script>` |