Project Summary: I leverage yt-dlp on a regular basis and wanted a way to automate the process to some extent. Therefore I wanted a way to add media URLs to a text file which yt-dlp could then read, download URLs, and start fresh. In addition I wanted the files to be made available in a particular folder on my Plex media server.
Structure and Workflow
Central to this structure is my Linux Mint desktop computer. This computer is on 24/7 and I have leveraged sshfs to connect to my Plex server\’s library directory structure. Obviously yt-dlp is installed on this computer. In order for this to work there are a few elements required:
- A text file where the URLs will be written to.
- A script which execute facilitate the process.
- A cronjob which will execute the script on a schedule.
- Optionally Nextcloud or other file syncing tool.
A blank and write enabled text file (in my case labeled youtube.md) is in my Nextcloud folder. My script will read the contents of the file and run yt-dlp with the –batch-file switch.
yt-dlp -P /home/USERNAME/Plex/video/new.arrivals --batch-file ~/Nextcloud/70-79.media/youtube.md &&
rm ~/Nextcloud/70-79.media/youtube.md && touch ~/Nextcloud/70-79.media/youtube.md
The script enters the "new arriavals" directory on the Plex server (effectively a directory linked via sshfs) and then executes yt-dlp, reading the youtube.md file. Once yt-dlp has completed downloading all of the URLs listed in the youtube.md file, the script will then remove the youtube.md file and then recreate it. This effectively creates a new blank file so URLs which have been previously downloaded are not downloaded again. I can then view the video files from my Plex server later.
Currently the script is scheduled to run every 15 minutes.
Potential Expansions
-
I optionally use Nextcloud in my setup because this allows me to add URLs to the youtube.md text file from anywhere as I have the Nextcloud app on my phone. There are times when someone
will send me a YT link to a video that I may want to keep or watch later. I can add it to the text file from my phone and the file will sync when I reconnect to my home network. I can connect via
VPN if I so choose. This means the video will likely be ready for me to view when I return. -
One may leverage the options of yt-dlp and expand the script to download specific YT channel content based upon a refined criteria such as content from a channel after a specific date.
See yt-dlp documentation for more options.