Created
January 25, 2024 01:17
-
-
Save e96031413/5d3a251197a089d7899e850d1b8791b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import os | |
urls = "https://drive.google.com/file/d/FILEID_1/view?usp=drive_link, https://drive.google.com/file/d/FILEID_2/view?usp=drive_link, https://drive.google.com/file/d/FILEID_3/view?usp=drive_link" | |
url_list = urls.split(', ') | |
pat = re.compile('https://drive.google.com/file/d/(.*)/view\?usp=drive_link') | |
for idx, url in enumerate(url_list): | |
g = pat.match(url) | |
id = g.group(1) | |
down_url = f'https://drive.google.com/uc?id={id}' | |
file_name = f"FILE_NAME_{idx}.zip" | |
os.system(f'curl -H "Authorization: Bearer ya29.a0AfB_XXXX_XXXXXXXX-XXXX_XXX-XXXXXXXXXXXX-XXXXXXXXX_XXXXXXXXXXXXXXXX-XXXXXXXXXXX_XXXX_XXXXXXXXX" https://www.googleapis.com/drive/v3/files/{id}?alt=media -o {file_name}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment