Google Drive

Google Drive Downloader allows you to download files from Google Drive and save them to a specified output directory. You can download files using a Google Drive file ID or shareable link.

circle-exclamation
chevron-rightPrerequisiteshashtag

If you want to try the snippet code in this page:

Installation

# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc"

Basic Usage

1

Create a script called main.py:

from gllm_docproc.downloader import GoogleDriveDownloader

source = "https://drive.google.com/file/d/1a2b3c4d5e6f7g8h9i0j/view?usp=sharing"
output_path = "./downloader/output"

# Initialize downloader
downloader = GoogleDriveDownloader(
    api_key="YOUR_GL_CONNECTORS_API_KEY",
    identifier="YOUR_GL_CONNECTORS_IDENTIFIER",
    secret="YOUR_GL_CONNECTORS_SECRET",
)

# Download file
downloaded_files = downloader.download(source, output_path)
print(f"Downloaded files: {downloaded_files}")
2

Run the script:

python main.py
3

The downloader will automatically extract the file ID from the URL and download the file.

circle-info

Source Input: The source parameter can be either a Google Drive URL or a direct file ID. The downloader automatically extracts the file ID from various Google Drive URL formats:

  • https://drive.google.com/file/d/FILE_ID/view

  • https://drive.google.com/open?id=FILE_ID

  • https://drive.google.com/uc?id=FILE_ID

  • https://docs.google.com/document/d/FILE_ID

  • https://docs.google.com/spreadsheets/d/FILE_ID

  • https://docs.google.com/presentation/d/FILE_ID

  • Direct file ID

Make sure your GL Connectors account has access to the file you want to download.

Last updated

Was this helpful?