Skip to content

Commit

Permalink
Add Check anilist API status
Browse files Browse the repository at this point in the history
  • Loading branch information
Arial-Z committed Nov 18, 2024
1 parent fead71e commit f019ee3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ function get-anilist-infos () {
-H 'content-type: application/json' \
--data '{ "query": "{ Media(type: ANIME, id: '"$anilist_id"') { relations { edges { relationType node { id type format title { romaji } status } } } title { romaji(stylised: false) english(stylised: false) native(stylised: false) } averageScore genres tags { name rank } studios { edges { node { name isAnimationStudio } } } startDate { year month } season seasonYear coverImage { extraLarge } status idMal} }" }' > "$SCRIPT_FOLDER/config/data/anilist-$anilist_id.json" -D "$SCRIPT_FOLDER/config/tmp/anilist-limit-rate.txt"
rate_limit=$(grep -oP '(?<=x-ratelimit-remaining: )[0-9]+' "$SCRIPT_FOLDER/config/tmp/anilist-limit-rate.txt")
if jq '.errors[].status' -r "$SCRIPT_FOLDER/data/anilist-$anilist_id.json" | grep -q -w "403"
then
rm "$SCRIPT_FOLDER/data/anilist-$anilist_id.json"
printf "%s - Error AniList API down, exiting\n" "$(date +%H:%M:%S)" | tee -a "$LOG"
exit 1
fi
((wait_time++))
if [[ $wait_time == 4 ]]
then
Expand Down

0 comments on commit f019ee3

Please sign in to comment.