Last active
December 11, 2015 00:38
-
-
Save laiso/4518114 to your computer and use it in GitHub Desktop.
Google Musicでアルバムとタイトルが重複した曲を削除するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtualenv.py | |
venv/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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