From 84ab4d71c913fc9649b2e7176787deadec235aeb Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 19 Feb 2023 14:21:24 +0100 Subject: disabled: yt-not.sh in favor of rss feeds --- config/X/xmonad/autostart/yt-not.sh | 63 ---------------------------- config/X/xmonad/autostart/yt-not.sh.disabled | 63 ++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 63 deletions(-) delete mode 100755 config/X/xmonad/autostart/yt-not.sh create mode 100755 config/X/xmonad/autostart/yt-not.sh.disabled (limited to 'config/X/xmonad') diff --git a/config/X/xmonad/autostart/yt-not.sh b/config/X/xmonad/autostart/yt-not.sh deleted file mode 100755 index a68f0c3..0000000 --- a/config/X/xmonad/autostart/yt-not.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash -ytnotdir="$HOME/.local/share/yt-not" - -get_notification() -{ - - cat "${ytnotdir}/channels.yt-not" | \ - while read line - do - channelId="$(echo "$line" | awk '{print $1}')" - ch_name="$(echo "$line" | awk '{print $2}')" - pre_vId="$(echo "$line" | awk '{print $3}')" - # Get last vid from xml feed - new_vId="$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}" | sed '/videoId/!d;s/^.*>\(.*\)<.*$/\1/g' | head -n1)" - if [ "$new_vId" != "$pre_vId" ] - then - dunstify "yt-notify" "NEW VID!! from\n${ch_name}" - newline=$(echo "$line" | sed "s/$pre_vId/$new_vId/") - sed -i "s/$line/$newline/" "${ytnotdir}/channels.yt-not" - fi - done -} - -# Two valid formats: -# 1: @channel -# 2: channelId @channel videoId -parse_channels() -{ - cat "${ytnotdir}/channels.yt-not" | \ - while read line - do - # First word of line is channelId or channelTag - chidot="$(echo "$line" | awk '{print $1}')" - # Tags start with @ - if [ "${chidot::1}" == "@" ] - then - # channel tag -> channelId - channelId="$(curl -s "https://www.youtube.com/${chidot}" | pup 'meta[itemprop="channelId"] attr{content}')" - sed -i "s/${chidot}/${channelId} ${chidot} novideo/" "${ytnotdir}/channels.yt-not" - fi - done -} - -main() -{ - mkdir -p "${ytnotdir}" - if [ ! -f "${ytnotdir}/channels.yt-not" ] - then - echo "@bugswriter_" > "${ytnotdir}/channels.yt-not" - echo "@DistroTube" >> "${ytnotdir}/channels.yt-not" - echo "@MentalOutlaw" >> "${ytnotdir}/channels.yt-not" - echo "@Fireship" >> "${ytnotdir}/channels.yt-not" - fi - - while true - do - sleep 15m - parse_channels - get_notification - done -} - -main diff --git a/config/X/xmonad/autostart/yt-not.sh.disabled b/config/X/xmonad/autostart/yt-not.sh.disabled new file mode 100755 index 0000000..a68f0c3 --- /dev/null +++ b/config/X/xmonad/autostart/yt-not.sh.disabled @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +ytnotdir="$HOME/.local/share/yt-not" + +get_notification() +{ + + cat "${ytnotdir}/channels.yt-not" | \ + while read line + do + channelId="$(echo "$line" | awk '{print $1}')" + ch_name="$(echo "$line" | awk '{print $2}')" + pre_vId="$(echo "$line" | awk '{print $3}')" + # Get last vid from xml feed + new_vId="$(curl -s "https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}" | sed '/videoId/!d;s/^.*>\(.*\)<.*$/\1/g' | head -n1)" + if [ "$new_vId" != "$pre_vId" ] + then + dunstify "yt-notify" "NEW VID!! from\n${ch_name}" + newline=$(echo "$line" | sed "s/$pre_vId/$new_vId/") + sed -i "s/$line/$newline/" "${ytnotdir}/channels.yt-not" + fi + done +} + +# Two valid formats: +# 1: @channel +# 2: channelId @channel videoId +parse_channels() +{ + cat "${ytnotdir}/channels.yt-not" | \ + while read line + do + # First word of line is channelId or channelTag + chidot="$(echo "$line" | awk '{print $1}')" + # Tags start with @ + if [ "${chidot::1}" == "@" ] + then + # channel tag -> channelId + channelId="$(curl -s "https://www.youtube.com/${chidot}" | pup 'meta[itemprop="channelId"] attr{content}')" + sed -i "s/${chidot}/${channelId} ${chidot} novideo/" "${ytnotdir}/channels.yt-not" + fi + done +} + +main() +{ + mkdir -p "${ytnotdir}" + if [ ! -f "${ytnotdir}/channels.yt-not" ] + then + echo "@bugswriter_" > "${ytnotdir}/channels.yt-not" + echo "@DistroTube" >> "${ytnotdir}/channels.yt-not" + echo "@MentalOutlaw" >> "${ytnotdir}/channels.yt-not" + echo "@Fireship" >> "${ytnotdir}/channels.yt-not" + fi + + while true + do + sleep 15m + parse_channels + get_notification + done +} + +main -- cgit v1.2.3