From d2915cefb5b4343c86841801f2d10b7c5122f575 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Wed, 17 Jul 2019 19:36:10 -0700 Subject: [PATCH] Add mobile_client.get_top_songs() to "Liked Songs" The current list of liked songs is only populated with those that happen to have been enumerated, leaving out songs that have been marked as thumbs up but are not in the library or a playlist. This patch explicitly walks the list from "get_top_songs()", which contains some of the songs that have been marked as thumbs up. The result is that my liked songs list matches what is shown on my phone. See https://github.com/simon-weber/gmusicapi/issues/637 for more information. Signed-off-by: Palmer Dabbelt --- clay/gp.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clay/gp.py b/clay/gp.py index e67268b..1e8ba57 100644 --- a/clay/gp.py +++ b/clay/gp.py @@ -95,6 +95,7 @@ class Track(object): SOURCE_STATION = 'station' SOURCE_PLAYLIST = 'playlist' SOURCE_SEARCH = 'search' + SOURCE_TOP = 'top' def __init__(self, source, data): # In playlist items and user uploaded songs the storeIds are missing so @@ -478,6 +479,10 @@ def add_liked_song(self, song): """ Add a liked song to the list. """ + for track in self._tracks: + if track.store_id == song.store_id: + return + self._tracks.insert(0, song) def remove_liked_song(self, song): @@ -601,6 +606,10 @@ def get_all_tracks(self): """ if self.cached_tracks: return self.cached_tracks + + for track in Track.from_data(self.mobile_client.get_top_songs(), Track.SOURCE_TOP, True): + pass + data = self.mobile_client.get_all_songs() self.cached_tracks = Track.from_data(data, Track.SOURCE_LIBRARY, True)