Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wget/curl large file from google drive

I'm trying to download a file from google drive in a script, and I'm having a little trouble doing so. The files I'm trying to download are here.

I've looked online extensively and I finally managed to get one of them to download. I got the UIDs of the files and the smaller one (1.6MB) downloads fine, however the larger file (3.7GB) always redirects to a page which asks me whether I want to proceed with the download without a virus scan. Could someone help me get past that screen?

Here's how I got the first file working -

curl -L "https://docs.google.com/uc?export=download&id=0Bz-w5tutuZIYeDU0VDRFWG9IVUE" > phlat-1.0.tar.gz 

When I run the same on the other file,

curl -L "https://docs.google.com/uc?export=download&id=0Bz-w5tutuZIYY3h5YlMzTjhnbGM" > index4phlat.tar.gz 

I get the the following output - enter image description here

I notice on the third-to-last line in the link, there a &confirm=JwkK which is a random 4 character string but suggests there's a way to add a confirmation to my URL. One of the links I visited suggested &confirm=no_antivirus but that's not working.

I hope someone here can help with this!

like image 449
Arjun Avatar asked Jul 29 '14 07:07

Arjun


People also ask

Can curl download from Google Drive?

When the shared files on Google Drive is downloaded, it is necessary to change the download method by the file size. The boundary of file size when the method is changed is about 40MB.

Can you wget from Google Drive?

Files can be downloaded from google drive using wget. Before that, you need to know that files are small and large-sized in google drive. Files less than 100MB are regarded as small files whereas files greater than 100MB are regarded as large files.

How do I download large files from Google Drive?

Downloading files from Google drive is same whether a large file or small size file. For Large file you just require a good quality internet connection. Go to that particular file, select it and press the mouse right click. Choose option download and choose a particular location on drive with sufficient space for file.

How do I download large files using wget?

If so, use wget -c as suggested by @dtmland. Finally, wget does have an option to limit file size but it is not set by default. One possibility is that your sysadmin has set a limit by making wget an alias to something like wget --max-filesize N . To check if wget is an alias run alias wget .


1 Answers

November 2021

You can use gdown. Consider also visiting that page for full instructions; this is just a summary and the source repo may have more up-to-date instructions.


Instructions

Install it with the following command:

pip install gdown 

After that, you can download any file from Google Drive by running one of these commands:

gdown https://drive.google.com/uc?id=<file_id>  # for files gdown --id <file_id>                            # alternative format gdown --folder https://drive.google.com/drive/folders/<file_id>  # for folders gdown --folder --id <file_id>                   # this format works for folders too 

Example: to download the readme file from this directory

gdown https://drive.google.com/uc?id=0B7EVK8r0v71pOXBhSUdJWU1MYUk 

The file_id should look something like 0Bz8a_Dbh9QhbNU3SGlFaDg. You can find this ID by right-clicking on the file of interest, and selecting Get link. As of November 2021, this link will be of the form:

# Files https://drive.google.com/file/d/<file_id>/view?usp=sharing # Folders https://drive.google.com/drive/folders/<file_id> 

Caveats

  • Only works on open access files. ("Anyone who has a link can View")
  • Cannot download more than 50 files into a single folder.
    • If you have access to the source file, you can consider using tar/zip to make it a single file to work around this limitation.
like image 134
phi Avatar answered Dec 11 '22 11:12

phi