Google Drive Direct Download for Large Files

google-drive

I am trying In Google Drive, how can you link directly to "Download" a zip file and not view the contents? but it does not work. I am not sure on how to repeat the question. It downloads a 'file is too big to be antivirus scanned' warning HTML and when I try https://drive.google.com/uc?export=download&confirm=no_antivirus&id= it still downloads that.

Edit: I tried to wget --save-cookies /tmp/cookie.txt --load-cookies /tmp/cookie.txt and repeat it, still no dice.

Best Answer

A cookie must match the "confirm" url parameter, and it is changed on each call.

Here's a perl script to download these files in an unattended way.

With the url from the antivirus scan warning page (https://drive.google.com/uc?export=download&confirm=s5vl&id=XXX) this code should be enough:

#!/usr/bin/perl
use strict;
my $TEMP='/tmp';my $COMMAND;my $confirm;
sub execute_command();
my $URL=shift;my $FILENAME=shift;
$FILENAME='gdown' if $FILENAME eq '';
execute_command();
if (-s $FILENAME < 100000) { # only if file isn't the download yet
    open fFILENAME, '<', $FILENAME;
    foreach (<fFILENAME>) {
        if (/confirm=([^;&]+)/) {
            $confirm=$1; last;   }    }
    close fFILENAME;
    $URL=~s/confirm=([^;&]+)/confirm=$confirm/;
    execute_command();    }
sub execute_command() {
    $COMMAND="wget --no-check-certificate --load-cookie $TEMP/cookie.txt --save-cookie $TEMP/cookie.txt \"$URL\"";
    $COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne '';
    `$COMMAND`; return 1;    }