Tracking Http Upload Progress Using Golang

I wrote a simple cli tool to upload files to my Cloudreve instance. It’s easy to figure out which api to call when uploading files. However, it will be helpful to know how the upload is going. Visualizing Speed When creating an upload request, golang allows us to use a io.Reader as the request body. The body will be responsible for displaying upload progress. info Although Cloudreve and its storage providers require Content-Length header to be set, thus requiring the total length to be known beforehand, this method is applicable even if the total is unknown....

published on December 10, 2023 · 3 min · 574 words

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 III

Previous post shows how to create a mpd manifest from the result of yt-dlp and play it using various players. However, there are some problems when we use the manifest with other tools such as ffmpeg and other video players rather than shaka-player and dash.js, mainly in the form of slow buffering. Determine the Cause of Slow Buffering First we determine how a browser requests YouTube assets. Open devtools: Request Query Parameters and Payload We can find the request is a POST request with query parameter range and payload x\n....

published on August 9, 2023 · 3 min · 555 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