当前位置: 首页>>代码示例>>Python>>正文


Python Track.set_genre方法代码示例

本文整理汇总了Python中lollypop.objects.Track.set_genre方法的典型用法代码示例。如果您正苦于以下问题:Python Track.set_genre方法的具体用法?Python Track.set_genre怎么用?Python Track.set_genre使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.objects.Track的用法示例。


在下文中一共展示了Track.set_genre方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_albums

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_genre [as 别名]
    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()
开发者ID:kmf,项目名称:lollypop,代码行数:61,代码来源:player.py

示例2: set_albums

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_genre [as 别名]
    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()
开发者ID:sebfag,项目名称:lollypop,代码行数:51,代码来源:player.py

示例3: set_albums

# 需要导入模块: from lollypop.objects import Track [as 别名]
# 或者: from lollypop.objects.Track import set_genre [as 别名]
    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)
开发者ID:sgnls,项目名称:lollypop,代码行数:63,代码来源:player.py


注:本文中的lollypop.objects.Track.set_genre方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。