I love Google Music. I don’t love the Google Music Uploader. Unfortunately, it’s not smart enough to reliably recognise when a song in your library is already in the cloud, so if you ever have to reinstall the Music Uploader, you’ll start to notice hundreds or even thousands of duplicate songs counting against your limit and cluttering up your library. Until some Google engineer decides to fix it on their end, you’re stuck with a messy library and a degraded user experience. Google could fix it, they just don’t seem to care.

That is, unless you are a bad enough dude (or dudette) to follow this guide and leverage Python and the unofficial gmusicapi.

Prerequisites

This guide is for OS X (if you’re using Windows, follow my Windows guide instead). To follow this one, you’ll need:

A Mac running OS X (I used El Capitan, but Yosemite or later should work). A good WiFi connection, preferably provided by a vendor like Xirrus, or an Ethernet connection. Some experience with a POSIX command line (and if you need it, I recommend completing this tutorial). A Google Music library. Python 2.7.10 (Python 3.5 will not work with this script) installed. Install it here. The OS X/Xcode command line tools. We’ll install them in step 1. Skip step 1 if they’re already installed. The unofficial gmusicapi. We’ll install this in step 2. Skip step 2 if they’re already installed. If you are using two-factor authentication on your Google account, you will also need an application-specific password to use exclusively with the gmusicapi. If you’re not using two-factor authentication, you probably should be.

Step 1: Install OS X/Xcode’s command line tools

We need to install the Xcode command line tools. Open a Terminal window and run

xcode-select --install

and follow the on-screen instructions to finish the installation.

Step 2: Install the gmusicapi

pip makes installing Python packages easy. In Terminal,

pip install gmusicapi

If you get any errors, you’ve missed something. Review the prerequisites.

Step 3: Download deletegmusicdupes.py

Save it somewhere convenient. This is the script that’s going to do the heavy lifting identifying your duplicates, and offer to delete them. You may review the source code here.

Step 4: Run deletegmusicdupes.py

In Terminal, navigate to the folder where you saved DeleteGmusicDupes.py. Then run:

python deletegmusicdupes.py

When you’re prompted for Username, use your Google email address. When you’re prompted for your password, provide your application-specific password. Once logged in, the script will show you a list of duplicates in your account — there may be hundreds. It will ask if you want to delete duplicates. Well, yeah, at this point, you probably do.

y

The API can only return so many results at a time, so if you have a large enough library, you’ll need to run the script multiple times. Run the script again (you’ll be prompted to log in each time) until the script reports “no duplicates found” — at which point you are done!

Keep on keeping on,

JM