Proxying Youtube Videos Part II

Previous post shows how to extract YouTube video assets using yt-dlp and implement a dynamic reverse proxy. This post details what the format YouTube is using. First we’ll find out what formats YouTube uses to stream high quality videos in a browser. Naive Solution There is an audio html element. We could try to synchronize an audio and a video element. However, it’s easier said than done as we have to consider not only play, pause, seek states, but also video and audio buffering, and it’s very easy to for these two elements to fall out of sync....

published on July 17, 2023 · 4 min · 752 words

Proxying Youtube Videos Part I

This series of posts details how to proxy YouTube videos. Unlike using tools to download YouTube videos, we’re proxying them so there is no need for a large storage system. This can be used to avoid ads and tracking and for other media streaming purpose. First we’ll learn how to extract YouTube video urls and write a simple dynamic reverse proxy. Extracting YouTube Video Urls If we want to proxy YouTube assets, first we’ll need to know the urls of the video assets....

published on July 3, 2023 · 3 min · 630 words

Using jd to Manage Caddy Configuration

Caddy is a powerful, extensible server written in go. Though its native configuration format is json, it supports Caddyfile which is very easy to write. For the majority of use cases, caddy’s default configuration is enough. For power users, however, some configurations are not exposed in Caddyfile and must be set using json. Because caddy config uses json format, we can use tools that modify json to produce caddy config....

published on June 19, 2023 · 2 min · 369 words

Porting ttyd to Golang Part II

Continuing from previous post, this post is about how to handle ttyd using golang. Overview The golang handler consists of 3 parts: sending frontend, sending auth token and handling websocket connection. Sending Frontend Golang can embed static assets in the compiled binary so there is no need to specify a path to the file. The frontend can be extracted using devtools. //go:embed ttyd.html var ttydHtml string func index(writer http.ResponseWriter, request *http....

published on June 7, 2023 · 6 min · 1229 words

Implementing A Multi-User Webdav Server

Golang comes with a webdav server implementation. It only supports webdav operations and nothing more. To manager a group of users, we need to implement our own handling logic. hacdias’s webdav server associates each user with his/her own webdav.Handler, and each authenticated request goes to their respective handler. rclone can generate dynamic webdav backends using auth proxy. By implementing auth proxy, rclone can serve different contents based on users. However, both of them suffer from lock states not shared, meaning when multiple users share the same directory, some changes may be lost if they try to modify its resources concurrently....

published on May 29, 2023 · 3 min · 621 words