sebbu

bangumi (bgm.tv) export

Aug 26th, 2025
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # https://next.bgm.tv/demo/access-token
  3. token=`cat bangumi_token.txt`
  4. curl -H "Authorization: Bearer $token" "https://api.bgm.tv/v0/me" -o me.json
  5. user=`cat me.json|jq -r .username|dos2unix`
  6. #types : 1 manga 2 anime 3 music 4 game 6 threeD
  7. types=(1 2 3 4 6)
  8. for type in ${types[@]}
  9. do
  10.         offset=0
  11.         num=0
  12.         limit=100
  13.         while true
  14.         do
  15.                 curl -H "Authorization: Bearer $token" "https://api.bgm.tv/v0/users/${user}/collections?subject_type=${type}&offset=${offset}&limit=${limit}" -o collections_${type}_${num}.json
  16.                 total=`cat collections_${type}_${num}.json | jq -r .total|dos2unix`
  17.                 offset2=`cat collections_${type}_${num}.json | jq -r .offset|dos2unix`
  18.                 limit2=`cat collections_${type}_${num}.json | jq -r .limit|dos2unix`
  19.                 ((num++))
  20.                 ((offset+=100))
  21.                 sum=`expr $offset2 + $limit2`
  22.                 [[ "$sum" -ge "$total" ]] && break 1
  23.         done
  24. done
Advertisement
Add Comment
Please, Sign In to add comment