summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaa <kaa@disroot.org>2025-07-29 23:51:08 -0700
committerkaa <kaa@disroot.org>2025-07-29 23:51:08 -0700
commit6301279036db4efe914ca5078481e20417229b60 (patch)
tree83e1d4701de9e392b2c633d52cb5c8f21efd9c1f
init
-rw-r--r--readme3
-rwxr-xr-xytpoll54
2 files changed, 57 insertions, 0 deletions
diff --git a/readme b/readme
new file mode 100644
index 0000000..289f0a1
--- /dev/null
+++ b/readme
@@ -0,0 +1,3 @@
+No more web browser, me happy.
+I come home, and new videos are waiting for me.
+Keep n low.
diff --git a/ytpoll b/ytpoll
new file mode 100755
index 0000000..6c7aa63
--- /dev/null
+++ b/ytpoll
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Channel URLs separated by spaces
+channels="https://www.youtube.com/channel/UCsvn_Po0SmunchJYOWpOxMg"
+# 720p60fps av1 codec
+vq=398
+# Best quality audio opus codec
+aq=251
+# output directory
+out=$HOME/vid/yt
+# number of latest videos
+n=10
+
+# internal use
+tmp=/tmp/ytpoll
+
+index()
+{
+ channel=$1
+ yt-dlp --flat-playlist -J $channel > $tmp
+}
+
+dl()
+{
+ video=$1
+
+ # 20250729 How I Met Goldilocks rg344jf29.webm
+ yt-dlp -o "$out/%(channel)s/%(upload_date)s %(fulltitle)s %(id)s.%(ext)s" -o "thumbnail:$out/%(channel)s/%(upload_date)s %(fulltitle)s %(id)s.%(ext)s" -o "description:$out/%(channel)s/%(upload_date)s %(fulltitle)s %(id)s.%(ext)s" --write-sub --write-auto-sub --sub-lang "en.*" --write-thumbnail --write-description --embed-metadata --embed-subs -f $vq+$aq $video
+}
+
+check()
+{
+ < $tmp jq -c '.entries[]' | head -$n | jq -c '.url, (.thumbnails | .[length - 1].url)' | paste - - | tr -d \" | while read -r video
+ do
+ url=$(echo $video | sed -e 's| .*||')
+ dl $url
+ done
+}
+
+while [ 1 ]
+do
+ date
+
+ for channel in $channels
+ do
+ index $channel
+ check
+ done
+
+ date
+
+ # 4 hour delay
+ sleep 14400
+done