#!/usr/bin/env sh if [ ! -d "$HOME/Bulk/Media/YouTube/.archives" ]; then mkdir -p "$HOME/Bulk/Media/YouTube/.archives" fi cd "$HOME/Bulk/Media/YouTube" || exit 1 dl() { if [ ! -f .archives/"$NAME".txt ]; then touch .archives/"$NAME".txt MOD_DATE=20200101 else MOD_DATE=$(stat -c %y .archives/"$NAME".txt | awk -F ' ' '{print $1}' | sed 's/-//g') fi yt-dlp --download-archive .archives/"$NAME".txt -f \ 'bestvideo[height<=2160]+bestaudio' \ --dateafter "$MOD_DATE" --write-sub \ --write-auto-sub --sub-format srt/best \ --sub-lang en --embed-subs \ --sponsorblock-mark sponsor,intro,outro,selfpromo,preview,interaction,chapter \ -o "%(uploader)s/%(upload_date)s - %(title)s (%(duration)s).%(ext)s" \ --playlist-end 5 "$URL" sleep 5 } while read -r NAME URL; do echo "Downloading videos from $NAME" dl "$NAME" "$URL" done < "$XDG_CONFIG_HOME/ytsubscriptions.txt" # Text file should be formatted as follows: # jack https://youtube.com/jack # jill https://youtube.com/jill notify-send "Downloads finished" "Check the YouTube folder for new videos"