Created
November 10, 2016 12:09
-
-
Save davidlonjon/aba1a43f6b8c9c447b0835aa50df8fc0 to your computer and use it in GitHub Desktop.
Revisions
-
davidlonjon created this gist
Nov 10, 2016 .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,62 @@ #!/usr/bin/perl # # Google Drive direct download of big files # ./gdown.pl 'gdrive file url' ['desired file name'] # # v1.0 by circulosmeos 04-2014. # http://circulosmeos.wordpress.com/2014/04/12/google-drive-direct-download-of-big-files # use strict; my $TEMP='/tmp'; my $COMMAND; my $confirm; my $check; sub execute_command(); my $URL=shift; die "\n./gdown.pl 'gdrive file url' [desired file name]\n\n" if $URL eq ''; my $FILENAME=shift; $FILENAME='gdown' if $FILENAME eq ''; execute_command(); while (-s $FILENAME < 100000) { # only if the file isn't the download yet open fFILENAME, '<', $FILENAME; $check=0; foreach (<fFILENAME>) { if (/href="(\/uc\?export=download[^"]+)/) { $URL='https://docs.google.com'.$1; $URL=~s/&/&/g; $confirm=''; $check=1; last; } if (/confirm=([^;&]+)/) { $confirm=$1; $check=1; last; } if (/"downloadUrl":"([^"]+)/) { $URL=$1; $URL=~s/\\u003d/=/g; $URL=~s/\\u0026/&/g; $confirm=''; $check=1; last; } } close fFILENAME; die "Couldn't download the file :-(\n" if ($check==0); $URL=~s/confirm=([^;&]+)/confirm=$confirm/ if $confirm ne ''; execute_command(); } sub execute_command() { $COMMAND="wget -nv --load-cookie $TEMP/cookie.txt --save-cookie $TEMP/cookie.txt \"$URL\""; $COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne ''; `$COMMAND`; printf("\nDownloading 578MB. Be patient..."); return 1; }