Last week, @yvan showed me a very cool way to watch youtube videos. You can browse the website, add videos to a private playlist, then have a script download that on your computer for later offline watch.
This is pretty amazing for a offline-first approach when it come to videos. Also helps reducing doom watching crap.
In the process, I learned that yt-dlp can:
1. download private youtube playlists from yt-dlp. It can even re-use your firefox cookies to authenticate to youtube.
2. Have yt-dlp cut out the sponsors via the sponsor block data.
The way to implement that is pretty simple:
1. Use `~/.config/yt-dlp/config` to add the sponsorblock and cookies flags.
```
$ cat ~/.config/yt-dlp/config
--sponsorblock-remove all
--cookies-from-browser firefox
```
2. Create a wrapper in charge of downloading your playlist. You need a download-archive to make sure you're not re-downloading stuff you downloaded in the past but already watched and removed.
```
» cat ~/.local/bin/yt-sync
#!/usr/bin/env bash
statedir="$HOME/.local/state/yt-sync/"
mkdir -p "$statedir"
yt-dlp --download-archive "$statedir/download-archive" -P "/tmp/" "https://www.youtube.com/playlist?list=LISTID"
```
3. Launch that manually, or, add a systemd user service and timer running this periodically. (I prefer the manual sync)
This is pretty amazing for a offline-first approach when it come to videos. Also helps reducing doom watching crap.
In the process, I learned that yt-dlp can:
1. download private youtube playlists from yt-dlp. It can even re-use your firefox cookies to authenticate to youtube.
2. Have yt-dlp cut out the sponsors via the sponsor block data.
The way to implement that is pretty simple:
1. Use `~/.config/yt-dlp/config` to add the sponsorblock and cookies flags.
```
$ cat ~/.config/yt-dlp/config
--sponsorblock-remove all
--cookies-from-browser firefox
```
2. Create a wrapper in charge of downloading your playlist. You need a download-archive to make sure you're not re-downloading stuff you downloaded in the past but already watched and removed.
```
» cat ~/.local/bin/yt-sync
#!/usr/bin/env bash
statedir="$HOME/.local/state/yt-sync/"
mkdir -p "$statedir"
yt-dlp --download-archive "$statedir/download-archive" -P "/tmp/" "https://www.youtube.com/playlist?list=LISTID"
```
3. Launch that manually, or, add a systemd user service and timer running this periodically. (I prefer the manual sync)