Skip to main content

Command Palette

Search for a command to run...

My 25 GB Mystery

and the Quest for Python + Google API Enlightenment

Published
3 min read

Since God knows how many years, I’ve been paying 3 Euros a month for a Google Drive subscription. One day, I found myself wondering: what on earth is taking up so much space there? I didn’t remember uploading anything on purpose – maybe just a few random documents for “just in case”, but nothing that could possibly weigh in at 25 GB.

This might sound silly to some, but it genuinely wasn’t obvious to me that photos and videos from Google Photos were taking up storage in Google Drive. I’ve always had a complicated relationship with subscriptions – they're sneaky. It’s way too easy to forget them and realise too late that your bank card is being drained for who-knows-what.

So the plan was simple: move everything to an external hard drive and cancel the subscription. But there was just one tiny problem: 25 gigabytes, Carl!
I value my time far too much to be clicking each file manually and choosing where to save it.

Now, I’d been meaning to practice automating tasks in Python – the one true universal language – and this felt like a great opportunity. Even better: the project led me straight into one of my favourite rabbit holes –APIs.

After a round of research, some half-blind wandering, and dozens of browser tabs later, I found myself staring at the interface of console.cloud.google.com, creating my very first project with slightly trembling hands.

The process was… surprisingly fun:

  1. Creating and naming the project on the Console – pretty smooth sailing here.

  2. Enabling the Google Drive API – this part wasn’t as smooth. The site decided to freeze, but refreshing showed it had worked. Then came the mystery of downloading the client_secrets.json file. For some reason, the download option wasn’t available at first. After 20 minutes of refreshing the page, disabling dark mode, switching browsers, and questioning my life choices, I gave up and generated a new secret key – which did allow me to download the file. Why this wasn’t available from the start remains a mystery. As they told me in childhood: “You’ll understand when you’re older.”

  3. Writing the Python script in VSCode:

     from pydrive2.auth import GoogleAuth
     from pydrive2.drive import GoogleDrive
     import os
     import re
    
     BASE_PATH = "/Volumes/My Passport for Mac/Videos/from Google Drive not_sorted"
    
     def extract_year(filename):
         match = re.search(r'VID_(\d{4})', filename)
         return match.group(1) if match else "Unknown"
    
     gauth = GoogleAuth()
     gauth.LocalWebserverAuth()
    
     drive = GoogleDrive(gauth)
    
     file_list = drive.ListFile({
         'q': "title contains 'VID_' and mimeType contains 'video/' and trashed=false"
     }).GetList()
    
     for file in file_list:
         year = extract_year(file['title'])
         save_dir = os.path.join(BASE_PATH, year)
         os.makedirs(save_dir, exist_ok=True)
    
         save_path = os.path.join(save_dir, file['title'])
    
         print(f"Downloading {file['title']}{save_path}")
         file.GetContentFile(save_path)
    
  4. Granting access to my own project – which, ironically, felt a little weird.

Everything was running perfectly. The script launched, authorisation succeeded... but none of the videos were found.

And that’s when I had my facepalm moment:
Google Drive ≠ Google Photos.
It was all going so well – until I realised I had connected the wrong API.

4 hours later ……

Unfortunately, I gave up in the end, since nothing was working the way I wanted. The folders on the external hard drive were created successfully, but the export process kept failing for various reasons — either access was denied, or the cloud folder couldn’t be found.

My goal was to free up space on Google Drive before the new subscription period started, so I ended up exporting all the photos manually, and managed to complete the entire process in just one day.

Still, I’m proud of myself for investing time in searching for an alternative solution. Even though it didn’t work out, I don’t consider that time wasted.

I’ll keep trying to come up with a way to automate this process, or at least, figure out why it isn’t working.