Uploaded by wokig53789

drive api code

advertisement
import os
import re
from googleapiclient.discovery import build
# Specify your API key
api_key = "x"
# Set up Drive API client
service = build('drive', 'v3', developerKey=api_key)
# Ask the user to input the directory URLs
directory_urls = []
while True:
directory_url = input("Enter a directory URL (or press Enter to stop): ")
if not directory_url:
break
else:
directory_urls.append(directory_url)
# Loop through each directory URL and print the download links for all files in
that directory
for directory_url in directory_urls:
# Extract the ID from the URL
match = re.search(r'[\w-]{25,}', directory_url)
if match:
directory_id = match.group()
else:
print('Invalid URL:', directory_url)
continue
Download