added nuked channel check to YT API requests

This commit is contained in:
Alexander Bocken 2021-06-26 19:54:10 +02:00
parent 2f12e793bd
commit 613b68748c
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

7
ripper
View File

@ -60,6 +60,8 @@ for channel_id in $IDs; do
echo "YT-ID: $channel_id" echo "YT-ID: $channel_id"
if [ -z "$LEGACYMODE" ]; then if [ -z "$LEGACYMODE" ]; then
json="$(curl -s "https://www.googleapis.com/youtube/v3/search?key=$APIKEY&channelId=$channel_id&part=snippet,id&order=date&maxResults=500")" json="$(curl -s "https://www.googleapis.com/youtube/v3/search?key=$APIKEY&channelId=$channel_id&part=snippet,id&order=date&maxResults=500")"
#Fallback to legacy mode if API quota is exceeded #Fallback to legacy mode if API quota is exceeded
if [ "$(echo "$json" | jq '."error"."errors"[]."reason"' 2> /dev/null )" = '"quotaExceeded"' ];then if [ "$(echo "$json" | jq '."error"."errors"[]."reason"' 2> /dev/null )" = '"quotaExceeded"' ];then
echo "YT API Quota exceeded, using fallback" echo "YT API Quota exceeded, using fallback"
@ -77,6 +79,10 @@ for channel_id in $IDs; do
sed 's|^\/feed\/entry\/yt:videoId=|https:\/\/www\.youtube\.com\/watch\?v=|' | sed 's|^\/feed\/entry\/yt:videoId=|https:\/\/www\.youtube\.com\/watch\?v=|' |
grep -vf "$BLACKLIST" >> /tmp/todownload$$ grep -vf "$BLACKLIST" >> /tmp/todownload$$
fi fi
else
if [ "$(echo "$json" | jq '.pageInfo.totalResults')" -eq 0 ];then
echo "Grabbing API data for channel returend no results"
echo "Is https://youtube.com/channel/$channel_id still up?"
else else
#Only try to download videos, not sheduled livestreams #Only try to download videos, not sheduled livestreams
echo "$json" | jq '.items[] | select(.snippet.liveBroadcastContent != "upcoming") | .id.videoId' | echo "$json" | jq '.items[] | select(.snippet.liveBroadcastContent != "upcoming") | .id.videoId' |
@ -84,6 +90,7 @@ for channel_id in $IDs; do
sed 's/^/https:\/\/www\.youtube\.com\/watch\?v=/' | sed 's/^/https:\/\/www\.youtube\.com\/watch\?v=/' |
grep -vf "$BLACKLIST" >> /tmp/todownload$$ grep -vf "$BLACKLIST" >> /tmp/todownload$$
fi fi
fi
done done
grep 'youtube' "$DLARCHIVE" | sed 's/youtube /https:\/\/www\.youtube\.com\/watch?v=/' > /tmp/alreadydownloaded$$ grep 'youtube' "$DLARCHIVE" | sed 's/youtube /https:\/\/www\.youtube\.com\/watch?v=/' > /tmp/alreadydownloaded$$