Last active
June 29, 2021 08:15
-
-
Save usr-ein/b8be16d2fe13be9e04ac4860cd35b36b to your computer and use it in GitHub Desktop.
wget any public file from Google Drive
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
wgetGdrive() { | |
if [ $# -lt 2 ]; then | |
echo "Usage $0 FILE_ID filename" | |
echo "FILE_ID looks like 1UkzAZMBG1U8kTqO3yhO2nTtoRNtEvyRq" | |
exit 1 | |
fi | |
# This is the proper way to create temp files | |
trap 'rm -f "$TMPFILE"' EXIT | |
COOKIES=$(mktemp) || exit 1 | |
CONFIRM=$(wget --quiet --save-cookies $COOKIES --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='"$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p') | |
wget --load-cookies $COOKIES "https://docs.google.com/uc?export=download&confirm=${CONFIRM}&id=${1}" -O $2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment