How to remove duplicates from your Google Music library using the gmusicapi and Cygwin on Windows
John M. Kuchta
610

Hi John, not sure if you still monitor this thread, but here goes…

I so thought this was going to work for me! I had recently run one of those MP3 repair tools. It rebuilt a ton of mp3s and renamed the original songname.bak. Google Music interpreted all these rebuilt MP3s as new songs and dutifully uploaded them. So I have tons of duplicates all of a sudden.

Note: Your instructions are excellent, though the openssl-devel package doesn’t appear in Devel. It seems to be in Net now. I installed it from there.

Running the script allows me to log in and it gets a ton of my songs. Then when I reply ‘y’ to delete duplicates, it returns these lines, followed by thousands more deletes. Then another bit of error-looking code at the bottom.

The first part, before all the deletes, is:

Delete duplicate songs? (y, n): y
Deleting songs …
Traceback (most recent call last):
 File “deletegmusicdupes.py”, line 46, in <module>
 client.delete_songs( old_song_ids )
 File “<decorator-gen-82>”, line 2, in delete_songs
 File “/usr/lib/python2.7/site-packages/gmusicapi/utils/utils.py”, line 619, in wrapper
 return function(*args, **kw)
 File “<decorator-gen-81>”, line 2, in delete_songs
 File “/usr/lib/python2.7/site-packages/gmusicapi/utils/utils.py”, line 317, in wrapper
 return function(*args, **kw)
 File “<decorator-gen-79>”, line 2, in delete_songs
 File “/usr/lib/python2.7/site-packages/gmusicapi/utils/utils.py”, line 596, in wrapper
 return function(*args, **kw)
 File “/usr/lib/python2.7/site-packages/gmusicapi/clients/mobileclient.py”, line 275, in delete_songs
 res = self._make_call(mutate_call, del_mutations)
 File “/usr/lib/python2.7/site-packages/gmusicapi/clients/shared.py”, line 84, in _make_call
 return protocol.perform(self.session, self.validate, *args, **kwargs)
 File “/usr/lib/python2.7/site-packages/gmusicapi/protocol/shared.py”, line 228, in perform
 raise CallFailure(err_msg, call_name)
gmusicapi.exceptions.CallFailure: BatchMutateTracks: 500 Server Error: Internal Server Error for url: https://mclients.googleapis.com/sj/v2.4/trackbatch?tier=fr&alt=json&hl=en_US
(requests kwargs: {u’url’: u’https://mclients.googleapis.com/sj/v2.4/trackbatch', u’headers’: {u’Content-Type’: u’application/json’, u’Authorization’: u’<omitted>’}, u’data’: ‘{“mutations”: [{“delete”: “6249af73–64ac-3dba-8565-a27540a1fc2a”}, and then thousands of deletes after this one…

and then…

{“delete”: “548d10ca-bdc6–3036-a6ec-64b238bb465b”}]}’, u’method’: u’POST’, u’params’: {u’tier’: u’fr’, u’alt’: u’json’, u’hl’: u’en_US’}})
(response was: u’{\n “error”: {\n “errors”: [\n {\n “domain”: “global”,\n “reason”: “internalError”,\n “message”: “Internal Error”\n }\n ],\n “code”: 500,\n “message”: “Internal Error”\n }\n}\n’)

Can you make heads or tails out of this? Nothing seems to be deleting in real life. Also, each time I run this script, the same list of songs appears, and what seems to be the same list of thousands of deletes with the same ID numbers (it appears — I checked the first and last ones and they are always the same.

Ugh, if you can make sense of any of that, my hat’s off to you!

Cheers,

Kurt B