Last active
August 26, 2024 09:28
-
-
Save ryul99/b51e939a6a459b4de60b361c6ab03818 to your computer and use it in GitHub Desktop.
Revisions
-
ryul99 renamed this gist
Aug 26, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ryul99 created this gist
Aug 26, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash # acknowledgement: # https://chemicloud.com/blog/download-google-drive-files-using-wget/#how-to-download-google-drive-files-using-wget # https://stackoverflow.com/a/6174447 function parse-url() { # extract the protocol proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')" # remove the protocol url="$(echo ${1/$proto/})" # extract the path (if any) file_id="$(echo $url | grep / | cut -d/ -f4)" echo $file_id } FILENAME=$2 if [[ -z $FILENAME ]]; then echo "File name is not set. Use 'google_file' as name" FILENAME='google_file' fi FILEID=$(parse-url $1) 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') wget --load-cookies /tmp/cookies.txt \ "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$FILEID" \ -O $FILENAME && rm -rf /tmp/cookies.txt