yt-dlp Scripts

These are some of my favorite scripts when using yt-dlp.

  • Download videos for the last week with the script below. This can be coupled with a cronjob for an effortless subscription which populates on your media server.

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' https://www.youtube.com/CHANNEL/videos

  • Downloads all videos in a playlist, appending the date of upload to the front of the name

yt-dlp --no-check-certificate -x --audio-format mp3 -o "%(upload_date>%Y-%m-%d)s.%(title)s.%(ext)s" [URL]

  • Downloads MP3s with the title and the date of upload.
    • This script can be used against the channel's "videos" URL to get the latest files, provide it is run from a directory with file downloaded previously with this script.

yt-dlp --no-check-certificate --embed-metadata -x --audio-format mp3 -o "%(upload_date>%Y-%m-%d)s.%(title)s.%(ext)s" [URL]

Download and Update

This bash script is helpful to essentially create your own RSS type retrieval system. This script will remove an existing playlist (if one exists), download the latest videos (and convert them to MP3 format) from a video channel/URL, and then creates a new m3u playlist which includes all of the files in the folder. This could be run on demand, or it could be a scheduled task (cronjob) which runs nightly.

#!/bin/bash

cd /path/to/folder/;
rm playlist.m3u;
yt-dlp --no-check-certificate -x --audio-format mp3 -o "%(upload_date>%Y-%m-%d)s.%(title)s.%(ext)s" [URL];
ls *.mp3 |sort > playlist.m3u;

done