Skip to content

Instantly share code, notes, and snippets.

@anon5r
Last active October 19, 2019 16:53
Show Gist options
  • Save anon5r/09bba46c287c9614aafb7ec6addc16f4 to your computer and use it in GitHub Desktop.
Save anon5r/09bba46c287c9614aafb7ec6addc16f4 to your computer and use it in GitHub Desktop.
Download FGO video
#!/bin/sh
#
# Usage:
# sh ./download_fgo_video.sh https://extend.data.fate-go.jp/xXxx0Xxx/PathCRC
#
# PathCRC URL
TARGET_URL=$1
FGO_VER='2.2.0.1'
UA="fategrandorder/$FGO_VER CFNetwork/1120 Darwin/19.0.0"
HEADERS='X-Unity-Version: 2018.4.4f1'
BASE_URL=$(echo $TARGET_URL | awk -F '/' -v 'OFS=/' '{print $1,$2,$3,$4}')
PATH_ID=$(echo $TARGET_URL | awk -F '/' '{print $4}')
LIST=$(curl -s -A "$UA" --header "$HEADERS" $TARGET_URL | awk -F ',' '{print $1}')
SCRIPT_PATH=$(dirname $0)
for REQ_PATH in $LIST
do
SAVEPATH=$(dirname $REQ_PATH)
if [ ! -e $SCRIPT_PATH/$SAVEPATH ] ; then
mkdir -p $SCRIPT_PATH/$SAVEPATH
fi
if [ -e $SCRIPT_PATH/$REQ_PATH ] ; then
rm $SCRIPT_PATH/$REQ_PATH
fi
curl -A "$UA" --header "$HEADERS" -s -o "$SCRIPT_PATH/$REQ_PATH" "$BASE_URL/$REQ_PATH"
COMPNAME=$(echo $REQ_PATH | awk -F '[/.]' '{print $3}')
COMPNAME="${COMPNAME}.mp4"
cat $SCRIPT_PATH/$REQ_PATH >> $SCRIPT_PATH/$COMPNAME
done
#rm -rf $SCRIPT_PATH/$SAVEPATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment