Skip to content

Instantly share code, notes, and snippets.

@amane-katagiri
Last active July 5, 2020 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amane-katagiri/783fe68477afbb996c59d9b692134be0 to your computer and use it in GitHub Desktop.
Save amane-katagiri/783fe68477afbb996c59d9b692134be0 to your computer and use it in GitHub Desktop.
ランダム・アニメ・ピックアップ
#!/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