0

I have a list of 100 urls that link to files on google drive that I want to download. Each url is like this:

https://drive.google.com/file/d/0B8asdfasdfasd4YXc/view?usp=sharing

How can I download them all in bulk? Ideally I'd put the urls in a text file and then something would download them all. They are videos

Ok, I can change the urls to this:

https://drive.google.com/uc?export=download&id=[TheFileID]

but I still have the click the "download anyway" button

4
  • Try using WGET. Commented Dec 10, 2016 at 20:39
  • I tried it but I get this: Resolving drive.google.com (drive.google.com)... 172.217.6.14 Connecting to drive.google.com (drive.google.com)|172.217.6.14|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] view?usp=sharing: No such file or directory
    – David
    Commented Dec 10, 2016 at 21:05
  • Ah, are the links open or do they require a logged in user? Commented Dec 10, 2016 at 21:50
  • I don't think they require you to be logged in but when you click the download icon upon opening a video in google drive it does give a warning that the file is too big to be scanned by a virus scanner. So maybe you have to go through all that before you can download each video but it would seem like someone has had this problem before and wrote a script to solve it.
    – David
    Commented Dec 10, 2016 at 22:39

2 Answers 2

1

I found an extension that will open multiple URLs. I changed download settings to not confirm and then I was able to paste a list of URLs in the format https://drive.google.com/uc?export=download&id=[TheFileID] to get them to all download.
Chrome extension called "Open Multiple URLs" https://chrome.google.com/webstore/detail/open-multiple-urls/oifijhaokejakekmnjmphonojcfkpbbh/related?hl=en

1

The steps

  1. Install gdown with pip install gdown - the command worked in a Standard Windows 11 PowerShell for me. (Make sure You have Python and Pip installed for this command)

  2. Make a .txt file with Your links, listed in the following manner:

https://drive.google.com/file/d/someID/view
https://drive.google.com/file/d/someotherID/view
and so on - Don't put anything that is not a link here
  1. Edit the variables at the top in the below script to fit Your needs.

  2. Run it

  3. If everything goes right - You'll find Your files in the directory You specified

The Script

from os import chdir
from typing import List
from gdown import download
from requests.exceptions import MissingSchema

my_links_file_path: str = r'C:\Users\Jakub\Desktop\a\download_links.txt'  # EDIT THIS!
my_output_directory_path: str = r'C:\Users\Jakub\Desktop\a'  # EDIT THIS!


def google_drive_bulk_download(links_file_path: str, output_directory_path: str):
    try:
        file = open(links_file_path, 'r')
    except FileNotFoundError:
        print(f"\n!!! The File '{links_file_path}' is Invalid!\n")
        return

    try:
        chdir(my_output_directory_path)
    except FileNotFoundError:
        print(f"\n!!! The File '{output_directory_path}' is Invalid!\n")
        return

    file_lines: List[str] = [stripped_line for stripped_line in
                             [line.strip() for line in file.readlines()]
                             if stripped_line]
    file_lines_count: int = len(file_lines)

    print('\n\n==> Started Downloading!\n')

    for i, url_raw in enumerate(file_lines, start=1):
        download_url: str = url_raw.strip()

        print(f'\n-> Downloading... [{i}/{file_lines_count}]')

        try:
            download(url=download_url, quiet=False, fuzzy=True)
        except: # If anyone knows what exact errors can gdown raise then please edit this answer to be more explicit or leave a comment. For now I will leave the 'bad practice' broad error catch
            print(f"!!! The URL '{download_url}' is Invalid or Failed To Download!")

        print('Finished!')

    print('\n\n==> Finished Downloading!')


google_drive_bulk_download(my_links_file_path, my_output_directory_path)

The Notes

  • This method worked for me. On Windows 11, Python 3.10 and Python 3.11.

  • This script may or may not work with other formats of google drive links.

  • You may want to try using a VPN if the Downloads fail - I had to.

  • There are many browser extensions that help You list the URLs of Your currently open browser tabs. No need to do it by hand.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .