From 487b85b223ad4da8adf2216d4e52925f504e58ba Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 2 Jan 2021 22:25:50 +0100 Subject: [PATCH] attempt to find correct YT channel URI if not correct --- .local/bin/tools/ripper | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.local/bin/tools/ripper b/.local/bin/tools/ripper index bdd8135..816781c 100755 --- a/.local/bin/tools/ripper +++ b/.local/bin/tools/ripper @@ -15,11 +15,11 @@ XDG_VIDEOS_DIR=$HOME/vids #TODO ADJUST FOR PERSONAL USE HERE! export XDG_VIDEOS_DIR DLARCHIVE="${XDG_VIDEOS_DIR:-$HOME/Videos}/.downloaded" DLLOC="${XDG_VIDEOS_DIR:-$HOME/Videos}" -CHANNELSFILE="${XDG_VIDEOS_DIR:-$HOME/Videos}/.channels" #FORMAT OF CHANNELSFILE: #Youtube: include the channel URI: https://www.youtube.com/channel/ #Bitchute: normal channel URI: https://www.bitchute.com/channel/ #Lines starting with '#' will be ignored in this file +CHANNELSFILE="${XDG_VIDEOS_DIR:-$HOME/Videos}/.channels" BLACKLIST="${XDG_VIDEOS_DIR:-$HOME/Videos}/.blacklist" # Required to display notifications if run as a cronjob: @@ -42,10 +42,13 @@ echo "Scanning for new Videos to download" ##YOUTUBE echo "Scanning on Youtube..." IDs="$( grep 'youtube' "$CHANNELSFILE" | grep -v '^#' | grep 'channel' | sed 's/https:\/\/www\.youtube\.com\/channel\///')" -not_correctly_formatted="$(grep 'youtube' "$CHANNELSFILE" | grep -v '^#' | grep -v 'channel')" +not_correctly_formatted="$(grep 'youtube' "$CHANNELSFILE" | grep -v '^#' | grep -v 'https:\/\/www\.youtube\.com\/channel\/')" if [ -n "$not_correctly_formatted" ]; then echo Please fix the following channel urls to be scannable: - echo "$not_correctly_formatted" + echo "$not_correctly_formatted" | while read -r line; do + printf 'Given URI:\t%s\n' "$line" + printf 'Potentiall correct channel URI:\n\thttps://youtube.com/channel/%s\n' "$(curl "$line" -s | grep -Eo 'externalId":"[^"]*"' | sed 's|^externalId":"||; s|"||g')" + done echo "They need to be in the 'https://www.youtube.com/channel/...' format" fi for channel_id in $IDs; do