Created
January 10, 2018 03:34
-
-
Save rosdyana/5072ccb01e01dcf21e8f8198d28c282e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
SOURCE="$1" | |
if [ "${SOURCE}" == "" ]; then | |
echo "Must specify a source url" | |
exit 1 | |
fi | |
DEST="$2" | |
if [ "${DEST}" == "" ]; then | |
echo "Must specify a destination filename" | |
exit 1 | |
fi | |
FILEID=$(echo $SOURCE | rev | cut -d= -f1 | rev) | |
COOKIES=$(mktemp) | |
CODE=$(wget --save-cookies $COOKIES --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=${FILEID}" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p') | |
# cleanup the code, format is 'Code: XXXX' | |
CODE=$(echo $CODE | rev | cut -d: -f1 | rev | xargs) | |
wget --load-cookies $COOKIES "https://docs.google.com/uc?export=download&confirm=${CODE}&id=${FILEID}" -O $DEST | |
rm -f $COOKIES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment