Created
October 19, 2012 09:13
-
-
Save k4nar/3917103 to your computer and use it in GitHub Desktop.
Download all Google Music's collection from user account. Uses gmusicapi (https://github.com/simon-weber/Unofficial-Google-Music-API)
This file contains 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
import os | |
from subprocess import call | |
from gmusicapi import api | |
g = api.Api() | |
print "Loging..." | |
g.login("email", "password") | |
print "OK !" | |
for song in g.get_all_songs(): | |
if not song["artist"]: | |
song["artist"] = "Undefined" | |
path = os.path.join("Musique", song["artist"]) | |
if not os.path.exists(path): | |
call(["mkdir", path]) | |
if not song["album"]: | |
song["album"] = "Undefined" | |
if song["year"]: | |
path = os.path.join(path, str(song["year"]) + " - " + song["album"]) | |
else: | |
path = os.path.join(path, song["album"]) | |
if not os.path.exists(path): | |
call(["mkdir", path]) | |
if song["track"]: | |
if song["track"] < 10: | |
song["track"] = "0" + str(song["track"]) | |
else: | |
song["track"] = str(song["track"]) | |
path = os.path.join(path, song["track"] + " - " + song["title"] + ".mp3") | |
else: | |
path = os.path.join(path, song["title"] + ".mp3") | |
print "PATH :", path | |
if not os.path.exists(path): | |
link, nb = g.get_song_download_info(song["id"]) | |
print "Downloading", link, "-", nb | |
call(["wget", link, "-O", path]) | |
print "---" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
l 23. os.mkdir(path)