Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 25, 2024 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/5d3a251197a089d7899e850d1b8791b8 to your computer and use it in GitHub Desktop.
Save e96031413/5d3a251197a089d7899e850d1b8791b8 to your computer and use it in GitHub Desktop.
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