Skip to content

Instantly share code, notes, and snippets.

@laiso
Last active December 11, 2015 00:38
Show Gist options
  • Save laiso/4518114 to your computer and use it in GitHub Desktop.
Save laiso/4518114 to your computer and use it in GitHub Desktop.
Google Musicでアルバムとタイトルが重複した曲を削除するスクリプト
virtualenv.py
venv/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
u"""
Google Musicでアルバムとタイトルが重複した曲を削除するスクリプト
curl -LO https://bitbucket.org/ianb/virtualenv/raw/tip/virtualenv.py
python virtualenv.py venv
venv/bin/easy_install gmusicapi
venv/bin/python gmusic_cleaner.py
"""
# https://github.com/simon-weber/Unofficial-Google-Music-API
from gmusicapi import Mobileclient
from getpass import getpass
email = raw_input("Email: ")
password = getpass()
api = Mobileclient()
api.login(email, password)
assert api.is_authenticated()
songs = api.get_all_songs()
assert len(songs) > 10
albums = []
titles = []
trash = []
for song in songs:
if song.get('album') in albums and song.get('title') in titles:
print "[delete] " + song.get('album', '').encode('utf_8') + " / " + song.get('title', '').encode('utf_8')
trash.append(song.get('id'))
albums.append(song.get('album'))
titles.append(song['title'])
if len(trash):
if raw_input("Delete duplicate songs? [y/n]: ") is 'y':
api.delete_songs(trash)
print "done\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment