1#!/usr/bin/env sh
2
3if [ ! -d "$HOME/Bulk/Media/YouTube/.archives" ]; then
4 mkdir -p "$HOME/Bulk/Media/YouTube/.archives"
5fi
6
7cd "$HOME/Bulk/Media/YouTube" || exit 1
8
9dl() {
10
11 if [ ! -f .archives/"$NAME".txt ]; then
12 touch .archives/"$NAME".txt
13 MOD_DATE=20200101
14 else
15 MOD_DATE=$(stat -c %y .archives/"$NAME".txt | awk -F ' ' '{print $1}' | sed 's/-//g')
16 fi
17
18 yt-dlp --download-archive .archives/"$NAME".txt -f \
19 'bestvideo[height<=2160]+bestaudio' \
20 --dateafter "$MOD_DATE" --write-sub \
21 --write-auto-sub --sub-format srt/best \
22 --sub-lang en --embed-subs \
23 --sponsorblock-mark sponsor,intro,outro,selfpromo,preview,interaction,chapter \
24 -o "%(uploader)s/%(upload_date)s - %(title)s (%(duration)s).%(ext)s" \
25 --playlist-end 5 "$URL"
26 sleep 5
27}
28
29while read -r NAME URL; do
30 echo "Downloading videos from $NAME"
31 dl "$NAME" "$URL"
32done < "$XDG_CONFIG_HOME/ytsubscriptions.txt"
33
34# Text file should be formatted as follows:
35# jack https://youtube.com/jack
36# jill https://youtube.com/jill
37
38notify-send "Downloads finished" "Check the YouTube folder for new videos"