Пример #1
0
    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()
Пример #2
0
    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()
Пример #3
0
    def set_albums(self, track_id, artist_id, genre_id):
        # Invalid track
        if track_id is None:
            return
        album_id = Lp.tracks.get_album_id(track_id)
        self._albums = None
        ShufflePlayer.reset_history(self)
        self.context.genre_id = genre_id

        # When shuffle from artist is active, we want only artist's albums,
        # we need to ignore genre
        # Do not set genre_id directly as it will changes current context
        if self._shuffle in [Shuffle.TRACKS_ARTIST, Shuffle.ALBUMS_ARTIST]:
            genre_id_lookup = None
        else:
            genre_id_lookup = genre_id

        # We are not playing a user playlist anymore
        self._user_playlist = None
        # We are in all artists
        if genre_id_lookup == 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_lookup == Type.POPULARS:
            self._albums = Lp.albums.get_populars()
        # We are in recents view, add recent albums
        elif genre_id_lookup == Type.RECENTS:
            self._albums = Lp.albums.get_recents()
        # We are in randoms view, add random albums
        elif genre_id_lookup == Type.RANDOMS:
            self._albums = Lp.albums.get_cached_randoms()
        # We are in compilation view without genre
        elif genre_id_lookup == 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_lookup)
        # Add all albums for genre
        else:
            self._albums = Lp.albums.get_compilations(genre_id_lookup)
            self._albums += Lp.albums.get_ids(None, genre_id_lookup)

        tracks = Lp.albums.get_tracks(album_id, genre_id_lookup)
        if track_id in tracks:
            self.context.position = tracks.index(track_id)
            self.context.genre_id = genre_id
            # Shuffle album list if needed
            self._shuffle_albums()
        elif self.current_track.id != Type.RADIOS:
            self.stop()
Пример #4
0
    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()
Пример #5
0
    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()
Пример #6
0
    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
        self._albums = []
        self._context.genre_ids = {}
        self._context.aritst_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):
            # Genres: all, Artists: compilations
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilation_ids()
            # Genres: all, Artists: ids
            elif artist_ids and artist_ids[0] != Type.ALL:
                self._albums += Lp().albums.get_ids(artist_ids)
            # Genres: all, Artists: all
            else:
                if Lp().settings.get_value("show-compilations"):
                    self._albums += Lp().albums.get_compilation_ids()
                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 loved view, add loved albums
        elif genre_ids and genre_ids[0] == Type.LOVED:
            self._albums = Lp().albums.get_loves()
        # 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_compilation_ids()
        # Add albums for artists/genres
        else:
            # If we are not in compilation view and show compilation is on,
            # add compilations
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilation_ids(genre_ids)
            else:
                if not artist_ids and\
                        Lp().settings.get_value("show-compilations"):
                    self._albums += Lp().albums.get_compilation_ids(genre_ids)
                self._albums += Lp().albums.get_ids(artist_ids, genre_ids)

        # 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] = []
            self._context.artist_ids[album_id] = []
            for genre_id in genre_ids:
                if genre_id >= 0:
                    self._context.genre_ids[album_id].append(genre_id)
            for artist_id in artist_ids:
                if artist_id >= 0:
                    self._context.artist_ids[album_id].append(artist_id)
        # Shuffle album list if needed
        self.shuffle_albums(True)
Пример #7
0
    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
        self._albums = []
        self._context.genre_ids = {}
        self._context.aritst_ids = {}
        self._context.prev_track = Track()
        self._context.next_track = Track()
        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):
            # Genres: all, Artists: compilations
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilations()
            # Genres: all, Artists: ids
            elif artist_ids and artist_ids[0] != Type.ALL:
                self._albums += Lp().albums.get_ids(artist_ids)
            # Genres: all, Artists: all
            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 artist_ids and artist_ids[0] == Type.COMPILATIONS:
                self._albums += Lp().albums.get_compilations(genre_ids)
            else:
                if not artist_ids 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] = []
            self._context.artist_ids[album_id] = []
            for genre_id in genre_ids:
                if genre_id >= 0:
                    self._context.genre_ids[album_id].append(genre_id)
            for artist_id in artist_ids:
                if artist_id >= 0:
                    self._context.artist_ids[album_id].append(artist_id)
        # Shuffle album list if needed
        self.shuffle_albums(True)