From 6301279036db4efe914ca5078481e20417229b60 Mon Sep 17 00:00:00 2001 From: kaa Date: Tue, 29 Jul 2025 23:51:08 -0700 Subject: init --- readme | 3 +++ ytpoll | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 readme create mode 100755 ytpoll 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 -- cgit v1.2.3