Created
April 20, 2021 02:23
-
-
Save syntaqx/086d96684c139e4608eb34f386a9188c to your computer and use it in GitHub Desktop.
Download and unzip directly 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
#!/usr/bin/env bash | |
set -e | |
# The file must be publically accessible: | |
# - Go to "Share" in the "More actions" dropdown | |
# - In the "Get Link" section, select "Change to anyone with this link" | |
# - You should see a link above the text: | |
# > Anyone with the link | |
# > Anyone on the internet with this link can view | |
# - Copy the url to your clipboard and set the value of $fileurl | |
fileurl="https://drive.google.com/file/d/12HAetsf1CIM_1o6CsT_xg6oC-PJPfOFk/view?usp=sharing" | |
tmpfile="$(mktemp)" | |
fileid=${fileurl%/*} | |
fileid=${fileid##*/} | |
wget -qO- --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$fileid" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$fileid" -O "$tmpfile" && rm -rf /tmp/cookies.txt | |
unzip -qo "$tmpfile" | |
rm -rf "$tmpfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment