def set_albums(self, track_id, artist_ids, genre_ids): """ Set album list (for next/prev) @param track id as int @param artist id as int @param genre id as int """ # Invalid track if track_id is None: return album = Track(track_id).album self._albums = [] ShufflePlayer.reset_history(self) # We are not playing a user playlist anymore self._user_playlist = [] self._user_playlist_id = None # We are in all artists if (genre_ids and genre_ids[0] == Type.ALL) or\ (artist_ids and artist_ids[0] == Type.ALL): self._albums = Lp().albums.get_compilations() self._albums += Lp().albums.get_ids() # We are in populars view, add popular albums elif genre_ids and genre_ids[0] == Type.POPULARS: if self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]: self._albums = [] self.next_track = Track() for album_id in Lp().albums.get_populars(): if Lp().albums.get_artist_id(album_id) == \ album.artist_id: self._albums.append(album_id) else: self._albums = Lp().albums.get_populars() # We are in recents view, add recent albums elif genre_ids and genre_ids[0] == Type.RECENTS: self._albums = Lp().albums.get_recents() # We are in randoms view, add random albums elif genre_ids and genre_ids[0] == Type.RANDOMS: self._albums = Lp().albums.get_cached_randoms() # We are in compilation view without genre elif genre_ids and genre_ids[0] == Type.COMPILATIONS: self._albums = Lp().albums.get_compilations() # Random tracks/albums for artist elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]: self._albums = Lp().albums.get_ids([album.artist_id], genre_ids) # Add all albums for genre else: if not artist_ids: self._albums = Lp().albums.get_compilations(genre_ids) self._albums += Lp().albums.get_ids(artist_ids, genre_ids) album.set_genre(genre_ids) if track_id in album.tracks_ids: self.context.artist_ids = artist_ids self.context.genre_ids = genre_ids # Shuffle album list if needed self._shuffle_albums() else: # Error self.stop()
def set_albums(self, track_id, artist_ids, genre_ids): """ Set album list (for next/prev) @param track id as int @param artist id as int @param genre id as int """ # Invalid track if track_id is None: return album = Track(track_id).album self._albums = [] ShufflePlayer.reset_history(self) # We are not playing a user playlist anymore self._user_playlist = [] self._user_playlist_id = None # We are in all artists if (genre_ids and genre_ids[0] == Type.ALL) or\ (artist_ids and artist_ids[0] == Type.ALL): self._albums = Lp().albums.get_compilations() self._albums += Lp().albums.get_ids() # We are in populars view, add popular albums elif genre_ids and genre_ids[0] == Type.POPULARS: if self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]: self._albums = [] for album_id in Lp().albums.get_populars(): if Lp().albums.get_artist_id(album_id) in artist_ids: self._albums.append(album_id) else: self._albums = Lp().albums.get_populars() # We are in recents view, add recent albums elif genre_ids and genre_ids[0] == Type.RECENTS: self._albums = Lp().albums.get_recents() # We are in randoms view, add random albums elif genre_ids and genre_ids[0] == Type.RANDOMS: self._albums = Lp().albums.get_cached_randoms() # We are in compilation view without genre elif genre_ids and genre_ids[0] == Type.COMPILATIONS: self._albums = Lp().albums.get_compilations() # Random tracks/albums for artist elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]: self._albums = Lp().albums.get_ids([album.artist_id], genre_ids) # Add all albums for genre else: if not artist_ids: self._albums = Lp().albums.get_compilations(genre_ids) self._albums += Lp().albums.get_ids(artist_ids, genre_ids) album.set_genre(genre_ids) if track_id in album.tracks_ids: self.context.artist_ids = artist_ids self.context.genre_ids = genre_ids # Shuffle album list if needed self._shuffle_albums() else: # Error self.stop()
def set_albums(self, track_id, artist_id, genre_id): """ Set album list (for next/prev) @param track id as int @param artist id as int @param genre id as int """ # Invalid track if track_id is None: return album = Track(track_id).album self._albums = None ShufflePlayer.reset_history(self) # We are not playing a user playlist anymore self._user_playlist = None self._user_playlist_id = None # We are in all artists if genre_id == Type.ALL or artist_id == Type.ALL: self._albums = Lp.albums.get_compilations(Type.ALL) self._albums += Lp.albums.get_ids() # We are in populars view, add popular albums elif genre_id == Type.POPULARS: self._albums = Lp.albums.get_populars() # We are in recents view, add recent albums elif genre_id == Type.RECENTS: self._albums = Lp.albums.get_recents() # We are in randoms view, add random albums elif genre_id == Type.RANDOMS: self._albums = Lp.albums.get_cached_randoms() # We are in compilation view without genre elif genre_id == Type.COMPILATIONS: self._albums = Lp.albums.get_compilations(None) # Random tracks/albums for artist elif self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]: self._albums = Lp.albums.get_ids(artist_id, genre_id) # Add all albums for genre else: self._albums = Lp.albums.get_compilations(genre_id) self._albums += Lp.albums.get_ids(None, genre_id) album.set_genre(genre_id) if track_id in album.tracks_ids: self.context.position = album.tracks_ids.index(track_id) self.context.genre_id = genre_id # Shuffle album list if needed self._shuffle_albums() else: # Error self.stop()
def set_albums(self, track_id, artist_ids, genre_ids): """ Set album list (for next/prev) @param track id as int @param artist id as int @param genre id as int """ # Invalid track if track_id is None: return album = Track(track_id).album album.set_genre(genre_ids) self._albums = [] self.context.genre_ids = {} ShufflePlayer.reset_history(self) # We are not playing a user playlist anymore self._user_playlist = [] self._user_playlist_ids = [] # We are in all artists if (genre_ids and genre_ids[0] == Type.ALL) or\ (artist_ids and artist_ids[0] == Type.ALL): if artist_ids and artist_ids[0] != Type.ALL: self._albums += Lp().albums.get_ids(artist_ids) else: if Lp().settings.get_value('show-compilations'): self._albums = Lp().albums.get_compilations() self._albums += Lp().albums.get_ids() # We are in populars view, add popular albums elif genre_ids and genre_ids[0] == Type.POPULARS: self._albums = Lp().albums.get_populars() # We are in recents view, add recent albums elif genre_ids and genre_ids[0] == Type.RECENTS: self._albums = Lp().albums.get_recents() # We are in randoms view, add random albums elif genre_ids and genre_ids[0] == Type.RANDOMS: self._albums = Lp().albums.get_cached_randoms() # We are in compilation view without genre elif genre_ids and genre_ids[0] == Type.COMPILATIONS: self._albums = Lp().albums.get_compilations() # Add albums for artists/genres else: # If we are not in compilation view and show compilation is on, # add compilations if (not artist_ids or artist_ids[0] != Type.COMPILATIONS) and\ Lp().settings.get_value('show-compilations'): self._albums += Lp().albums.get_compilations(genre_ids) self._albums += Lp().albums.get_ids(artist_ids, genre_ids) if Lp().settings.get_value('repeat'): self.context.next = NextContext.NONE else: self.context.next = NextContext.STOP_ALL # We do not store genre_ids for ALL/POPULARS/... if genre_ids and genre_ids[0] < 0: genre_ids = [] # Set context for each album for album_id in self._albums: self.context.genre_ids[album_id] = genre_ids # Shuffle album list if needed self.shuffle_albums(True)