Skip to content

Instantly share code, notes, and snippets.

@Sohil876
Created February 29, 2020 18:17
Show Gist options
  • Save Sohil876/a00e91408527d06626e5b29cf978fd48 to your computer and use it in GitHub Desktop.
Save Sohil876/a00e91408527d06626e5b29cf978fd48 to your computer and use it in GitHub Desktop.
-:Download Gdrive files through Wget:-
Command for downloading any big file from google drive (for big file we need confirm download)
wget --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 FILENAME && rm -rf /tmp/cookies.txt
I've used @beliys code and made a bash command.
Setup:
Add this code to your ~/.bash_aliases file.
function gdrive_download () {
CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --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 /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
rm -rf /tmp/cookies.txt
}
Open new bash session.
Usage:
gdrive_download long_google_drive_file_id filename.ext
https://github.com/GitHub30/gdrive.sh
https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive/32441141#32441141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment