diff --git a/mopidy_gmusic/library.py b/mopidy_gmusic/library.py index 9bad6f0..8700c4d 100644 --- a/mopidy_gmusic/library.py +++ b/mopidy_gmusic/library.py @@ -373,6 +373,8 @@ def sorter(track): return sorted(tracks, key=sorter) def refresh(self, uri=None): + logger.info("Refreshing library") + self.tracks = {} self.albums = {} self.artists = {} @@ -407,6 +409,13 @@ def refresh(self, uri=None): for artist in album.artists: self.artists[artist.uri] = artist + logger.info( + "Loaded " + f"{len(self.artists)} artists, " + f"{len(self.albums)} albums, " + f"{len(self.tracks)} tracks from Google Play Music" + ) + def search(self, query=None, uris=None, exact=False): if exact: return self._find_exact(query=query, uris=uris) @@ -589,9 +598,7 @@ def _to_mopidy_album(self, song): artist = self._to_mopidy_album_artist(song) date = str(song.get("year", 0)) - album_id = song.get("albumId") - if album_id is None: - album_id = create_id(artist.name + name + date) + album_id = create_id(f"{artist.name}|{name}|{date}") uri = "gmusic:album:" + album_id return Album( @@ -605,11 +612,7 @@ def _to_mopidy_album(self, song): def _to_mopidy_artist(self, song): name = song.get("artist", "") - artist_id = song.get("artistId") - if artist_id is not None: - artist_id = artist_id[0] - else: - artist_id = create_id(name) + artist_id = create_id(name) uri = "gmusic:artist:" + artist_id return Artist(uri=uri, name=name)