Ytsub

Ytsub is a script written to be executed through a cronjob and designed to download videos from video services supported by yt-dlp. This script requires and leverages yt-dlp. The script will search the feed URL supplied for videos that have been posted in the last week from the date of execution. It will also delete any downloaded videos aged 30 day or older to conserve disk space. The number of days can be changed to your preference.

If used in conjuntion with a media server, this script will effectively facilitate a private video subscription service without being logged into said service. You just get to open your media server app and see the latest and greatest of your favorite channels.

Enjoy!

#!/bin/bash
# Video subscription script.
# This script will download videos uploaded to a specificed channel in the past week from the time 
# of execution.

# List of channels, a.k.a. subscriptions
channel1=https://www.youtube.com/@CHANNEL/videos
channel2=
channel3=
channel4=
channel5=
channel6=
channel7=
channel8=
channel9=
channel10=


# Commands to download the channel's videos

cd /path/to/downloaded/videos

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel1

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel2

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel3

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel4

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel5

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel6

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel7

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel8

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel9

yt-dlp --dateafter today-1week -f mp4 -o '%(title)s.%(ext)s' $channel10

cd

# This line will delete any file older than 30 days. This is to maintain
# disk space.

find /path/to/downloaded/videos/* -mtime +30 -exec rm {} \;

exit 0