Archiving a YouTube Channel

Archiving a YouTube channel with yt-dlp

07-07-24

Table of Contents

Prerequisites

Install youtube-dl or yt-dlp.

Process

Initial archive

The initial channel archive can be completed with a simple command:

yt-dlp --add-metadata <channel url>

Note that yt-dlp automatically passes the -f bestvideo*+bestaudio/best flag. Specify your desired format if applicable.

Auto-archive new videos

To continue auto-archiving the channel:

#!/bin/sh
while IFS= read line; do
        yt-dlp --add-metadata --dateafter now-1week --break-on-reject --download-archive "</path/to/directory>/<channel list>.txt" -o "</path/to/directory>/%(title)s.%(ext)s" "$line"
done < </path/to/directory>/<channel list>.txt

Where:

This will fetch the last week’s worth of content. If content has already been downloaded, it will be skipped without error.

Example below:

while IFS= read line; do
        yt-dlp --add-metadata --dateafter now-1week --break-on-reject --download-archive ~/archive.txt -o "~/vault/videos/new/%(title)s.%(ext)s" "$line"
done < ~/channels.txt

To run this automatically, add it to the crontab:

crontab -e
~~~
* */6 * * * ytld-cron.sh

I run mine four times per day.

Troubleshooting

Rate-limiting

Occasionally, YouTube will rate limit downloads. The initial download may progress at normal speed, but subsequent videos will be limited to Kb/s.

One solution is to load any YouTube video while downloading. Leave a long video on loop during the duration of the download.

You may also try lowering --throttled-rate to the highest Kb/s rate occuring when downloading.


Tagged: Archival