isayahc's picture
created function for google drive download
7c39d08
raw
history blame
716 Bytes
import gdown
from typing import Optional
def download_from_google_drive(file_id: str, destination: Optional[str] = None) -> None:
"""
Download a file from Google Drive using its file ID.
:param file_id: The file ID on Google Drive.
:param destination: The path to save the file. If None, the file will be saved in the current directory with its original name.
"""
url = f'https://drive.google.com/uc?id={file_id}'
output = destination if destination else f"{file_id}.file"
gdown.download(url, output, quiet=False)
if __name__ == '__main__':
# Example usage
file_id = "1hnzY7sd8jBgyEu_gEQj9FTnAxBZPYa80" # Replace with your file ID
download_from_google_drive(file_id)