-- Leo's gemini proxy

-- Connecting to voidcruiser.nl:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

YouTube sucks


A few days ago at time of writing, YouTube decided to fuck around with how their website works again, preventing Invidious from playing videos. Funnily enough, yt-dlp still works with YouTube's own domain. So I've gotten into the habit of using my private Invidious instance to keep track of the YouTube channels I care about, then downloading the videos I want to watch using yt-dlp and watching them either with MPV or my local Jellyfin instance. In case of the former, I have the annoying tendency to forget to delete videos once I've watched them, which has resulted in a full disk one to many times.

The solution I've come up with is to use part of my RAM as an 8GB tmpfs partition to download videos onto and then unmount once I'm done.


Here's how to do that


1. Create a tmpfs session with roughly the following command:

sudo mount -o size=8G -t tmpfs none /desired/mount/point

You'll probably want to change the ownership of this directory as it'll default to belonging to the root user.


2. Download a given video with yt-dlp; my favourite command is as follows:

yt-dlp --embed-chapters --embed-metadata --embed-subs <youtube-url>

3. Once you want to get rid of those videos, simply umount the partition. Or if you're scatterbrained like me, rebooting your computer will obviously also get rid of the video files still in memory.


Scripting


Since I'm using my own Invidious instance and can't exactly be bothered to substitute its domain for 'youtube.com' by hand, I wrote a script in Nushell that does that for me:


#!/usr/bin/env nu

def main [url: string] {
	let parsed_url = $url | url parse

	let yt_url = if ($parsed_url.path | str contains '/watch') {
		if $parsed_url.host != "youtube.com" {
			$url | str replace $parsed_url.host "youtube.com"
		} else {
			$url
		}
	} else {
		error make {
			msg: "Not a YouTube/Invidious/Piped URL"
			label: {
				text: "Expects a YouTube/Invidious/Piped URL"
				span: (metadata $url).span
			}
		}
	}

	yt-dlp --embed-chapters --embed-metadata --embed-subs $yt_url
}

The script can also be found here.


Back

-- Response ended

-- Page fetched on Sat May 18 15:53:43 2024