iXce / gmusicimport

Simple playlist importer for Google Play Music
14 stars 9 forks source link

Fixes for latest gmusicapi #8

Open aonic opened 7 years ago

aonic commented 7 years ago

Here are the changes needed to make this compatible with the latest gmusicapi

diff --git a/gmusicimport.py b/gmusicimport.py
index b3bccd0..057fd1d 100755
--- a/gmusicimport.py
+++ b/gmusicimport.py
@@ -35,7 +35,7 @@ if __name__ == "__main__":
     args = parser.parse_args()
     print("Logging in as \"%s\" to Google Play Music" % args.username)
     pw = getpass.getpass()
-    if not client.login(args.username, pw):
+    if not client.login(args.username, pw, Mobileclient.FROM_MAC_ADDRESS):
         print("Authentication failed. Please check the provided credentials.")
     with open(args.source) as f:
         data = json.load(f)
@@ -48,14 +48,15 @@ if __name__ == "__main__":
             print("Importing %s" % playlist["title"])
         toimport = []
         for track in playlist["tracks"]:
-            query = "%s %s" % (track["title"], track["artist"])
-            results = client.search_all_access(query)
+            query = "%s %s" % (track["title"].replace('Album Version', ''), track["artist"])
+            results = client.search(query)
             match = None
             if args.verbose:
                 print("Fetching matches for %s" % query)
             for hit_i, hit in enumerate(results["song_hits"]):
                 if hit_i >= 10:
                     break
+                hit['score'] = 1000.0 # new API doesnt return score
                 if args.verbose and hit_i < 10:
                     print("Hit %d, scoring %.02f: %s by %s in %s" %
                             (hit_i + 1,
iXce commented 7 years ago

mind doing a PR ? :)

aonic commented 7 years ago

Fine! :) give me a day