Skip to content

Instantly share code, notes, and snippets.

@py7hon
Created April 12, 2020 13:42
Show Gist options
  • Save py7hon/1623fd16985581eba68eaaca761b6a55 to your computer and use it in GitHub Desktop.
Save py7hon/1623fd16985581eba68eaaca761b6a55 to your computer and use it in GitHub Desktop.
google drive downloader
api = "AIzaSyBPO_VhHtvTL-gs35Nb24cSsjuxQasjlN0"
file_id=""
i = ""
list1 = []
while i != "q":
i = input("Enter URL: ")
list1.append(i)
list1.pop(-1)
for link in list1:
if link.find("file/d/") != -1:
id_part = link.find("file/d/")
id = link[id_part+7:]
new_id = id.replace("/view?usp=drivesdk", "")
final_url = f"https://www.googleapis.com/drive/v3/files/{new_id}?alt=media&key={api}"
print(f"""
{final_url}
""")
elif link.find("&export=download") == -1:
id_part = link.find("id=")
id = link[id_part+3:]
#print(id)
final_url = f"https://www.googleapis.com/drive/v3/files/{id}?alt=media&key={api}"
print(f"""
{final_url}
""")
else:
id_part = link.find("id=")
id = link[id_part+3:-16]
final_url = f"https://www.googleapis.com/drive/v3/files/{id}?alt=media&key={api}"
print(f"""
{final_url}
""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment