Last active
July 5, 2020 11:58
-
-
Save amane-katagiri/783fe68477afbb996c59d9b692134be0 to your computer and use it in GitHub Desktop.
ランダム・アニメ・ピックアップ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -Ceu | |
URL_ROOT='https://anime.dmkt-sp.jp/animestore/rest/WS000108' | |
LENGTH=300 | |
for KANA_COLUMN in $(seq 1 10); do | |
for KANA_ROW in $(seq 1 5); do | |
TEMP=$(mktemp) | |
curl -o $TEMP -Ss "$URL_ROOT"'?workTypeList=anime&length='"$LENGTH"'&initialCollectionKey='"$KANA_COLUMN"'&consonantKey='"$KANA_ROW"'&vodTypeList=svod_tvod' | |
ERROR="$(cat $TEMP | jq -r '.error.code')" | |
if [ "$ERROR" == "null" ]; then | |
RESULT_MAX_COUNT="$(cat $TEMP | jq -r '.data.maxCount')" | |
RESULT_COUNT="$(cat $TEMP | jq -r '.data.count')" | |
if [ "$RESULT_MAX_COUNT" -ne "$RESULT_COUNT" ]; then # ページネーションしたくない | |
echo 'maxCount == count: '"$RESULT_MAX_COUNT"' == '"$RESULT_COUNT" >&2 | |
exit 1 | |
fi | |
cat $TEMP | jq -r '.data.workList[].workInfo.link' | |
elif [ "$ERROR" != "21" ]; then # や行とわ行でのエラーは無視 | |
echo 'unexpected error: '"$ERROR" >&2 | |
exit 1 | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment