User:FabulousCupcake/character-asset-download.sh

From Granblue Fantasy Wiki
Jump to navigation Jump to search
#!/bin/sh

if [ -z "$1" ]
  then
    script=`basename "$0"`
    echo "Downloads standard granblue character image assets by id."
    echo "    Usage: ./${script} <id> [uncap]"
    echo "  Example:"
    echo "    ./${script} 3040178000"
    echo "    ./${script} 3040178000 2"
    exit
fi

ID="$1"
UNCAP="${2:-1}"                 # `$2` if defined, otherwise `1`
UNCAP=$(printf "%02d" ${UNCAP}) # leftpads with '0' until it's 2 digits long

# Generate links
  ZOOM="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/zoom/${ID}_${UNCAP}.png"
MYPAGE="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/my/${ID}_${UNCAP}.png"
 PARTY="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/f/${ID}_${UNCAP}.jpg"
  MINI="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/m/${ID}_${UNCAP}.jpg"
DETAIL="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/detail/${ID}_${UNCAP}.png"
 QUEST="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/quest/${ID}_${UNCAP}.jpg"
  RAID="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/raid_normal/${ID}_${UNCAP}.jpg"
SPRITE="http://game-a.granbluefantasy.jp/assets_en/img/sp/assets/npc/sd/${ID}_${UNCAP}.png"

# Download links
IMAGE_SET=($ZOOM $MYPAGE $PARTY $MINI $DETAIL $QUEST $RAID $SPRITE)
for LINK in ${IMAGE_SET[@]}; do
  PATHNAME=$(echo $LINK | cut -d"/" -f 9)
  EXTENSION=${LINK:(-3)}
  FILENAME="${ID}_${UNCAP}_${PATHNAME}.${EXTENSION}"
  echo "${FILENAME}…"
  curl -# $LINK -o $FILENAME
done