Spaces:
Runtime error
Runtime error
created function for google drive download
Browse files
utils.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gdown
|
2 |
+
from typing import Optional
|
3 |
+
|
4 |
+
def download_from_google_drive(file_id: str, destination: Optional[str] = None) -> None:
|
5 |
+
"""
|
6 |
+
Download a file from Google Drive using its file ID.
|
7 |
+
|
8 |
+
:param file_id: The file ID on Google Drive.
|
9 |
+
:param destination: The path to save the file. If None, the file will be saved in the current directory with its original name.
|
10 |
+
"""
|
11 |
+
url = f'https://drive.google.com/uc?id={file_id}'
|
12 |
+
output = destination if destination else f"{file_id}.file"
|
13 |
+
gdown.download(url, output, quiet=False)
|
14 |
+
|
15 |
+
|
16 |
+
if __name__ == '__main__':
|
17 |
+
# Example usage
|
18 |
+
file_id = "1hnzY7sd8jBgyEu_gEQj9FTnAxBZPYa80" # Replace with your file ID
|
19 |
+
download_from_google_drive(file_id)
|