no error output if quota not exceeded

This commit is contained in:
Alexander Bocken 2021-01-03 11:28:34 +01:00
parent 8c7b37ebe2
commit e570157267
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -56,7 +56,7 @@ for channel_id in $IDs; do
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")"
#Fallback to legacy mode if API quota is exceeded
if [ "$(echo "$json" | jq '."error"."errors"[]."reason"')" = '"quotaExceeded"' ];then
if [ "$(echo "$json" | jq '."error"."errors"[]."reason"' 2> /dev/null )" = '"quotaExceeded"' ];then
echo "YT API Quota exceeded, using fallback"
LEGACYMODE=1
fi