Implementing JSON RPC With Python

In a previous post, I mentioned using yt-dlp as a service to extract YouTube information. The method I used has one serious problems: it uses a custom protocol that serves one request per connection and dumps the error as a string if any. To find out if there is an error, we have to parse the result first and if it’s not a valid json string, we can be sure there’s an error....

published on September 6, 2023 · last edited on September 15, 2023 · 5 min · 908 words

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