Last active
April 11, 2022 20:56
-
-
Save rama982/222c3bdaa6a1160288b6f0d17045cead to your computer and use it in GitHub Desktop.
Script to download large files from google drive using curl
This file contains 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 | |
# Script to download large files from google drive using curl | |
# Source https://stackoverflow.com/a/38937732 | |
# Edited by rama982 | |
# Usage example: bash gdcurl.sh 1WPyPIX07W4diry8ZifQWZlPpDa4UWg2s cookies.txt | |
# google file ID | |
ggID=$1 | |
# google url | |
ggURL='https://drive.google.com/uc?export=download' | |
# if file need to login before download, provide your own cookies.txt | |
[[ ! -z "$2" ]] && LOGIN="-b $2" | |
# get filename | |
filename="$(curl $LOGIN -sc /tmp/gcokie "${ggURL}&id=${ggID}" | grep -o '="uc-name.*</span>' | sed 's/.*">//;s/<.a> .*//')" | |
[ -z "$filename" ] && exit | |
echo "Filename: $filename" | |
# execute download | |
curl -Lb /tmp/gcokie "${ggURL}&confirm=t&id=${ggID}" -o "${filename}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment