The bane of our dev days of late. A recent update with Google Drive has made it so that it is rather difficult to get any direct links to an uploaded image/file and download it. We used to be able to right-click it and select copy image, which we could paste into some auto-downloader (aela). But now, one cannot even right click in a Google Drive file. They make it so that it looks like the only downloading-type of action you can take is if you click on their specifically designed Download button.

Here’s what a link to the Abbey Road promo picture looks like:

We need to convert the first link into the second so that we can download it with the Python requests module. Notice that the only important part in the two links is the id, which is 1CKQVt2nirGUH9BE6wBLeSE8FieyMepd_ in this case.

So we can just extract that unique file identifier and rebuild the second link, inserting the id in the right spot.

def downloadGDrive(link, imageFolder, imgCount):
# you can do something like link.split('/')[-2], which will split the link
# into items at a / character, and we want the 2nd-to-last item

# This stuff will get the original file name so that we can name our downloaded file with the original file name
fname = re.findall("filename=(.+)", d)
if len(fname) > 0:
name = fname[0].split(';')[0]
name = name.replace(" ", "-").strip('"')
else:
localFileName = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S_") + imgCount + "-" + name
localPath = "discord-wips/" + imageFolder + "/" + localFileName
if response.status_code == 200:
try:
os.makedirs(imageFolder)
except FileExistsError:
return localPath, localFileName, success`