コード例 #1
0
ファイル: client.py プロジェクト: fldc/Spotify.bundle
 def is_track_playable(self, track):
     ''' Check if a track can be played by a client or not '''
     playable = True
     assert_loaded(track)
     if track.is_local():
         playable = False
     elif not track.availability():
         playable = False
     return playable
コード例 #2
0
ファイル: client.py プロジェクト: jarlebh/Spotify.bundle
 def is_track_playable(self, track):
     ''' Check if a track can be played by a client or not '''
     playable = True
     assert_loaded(track)
     if track.is_local():
         playable = False
     elif not track.availability():
         playable = False
     return playable
コード例 #3
0
ファイル: client.py プロジェクト: fldc/Spotify.bundle
    def wait_until_loaded(self, spotify_object, timeout):
        ''' Poll a spotify object until it is loaded

        :param spotify_object:   The spotify object to poll.
        :param timeout:          A timeout in seconds.
        '''
        start = time()
        while not spotify_object.is_loaded() and start > time() - timeout:
            message = "Waiting for spotify object: %s" % spotify_object
            self.log(message, debug = True)
            self.session.process_events()
            sleep(POLL_INTERVAL)
        assert_loaded(spotify_object)
        return spotify_object
コード例 #4
0
ファイル: client.py プロジェクト: jarlebh/Spotify.bundle
    def wait_until_loaded(self, spotify_object, timeout):
        ''' Poll a spotify object until it is loaded

        :param spotify_object:   The spotify object to poll.
        :param timeout:          A timeout in seconds.
        '''
        start = time()
        while not spotify_object.is_loaded() and start > time() - timeout:
            message = "Waiting for spotify object: %s" % spotify_object
            self.log(message, debug=True)
            self.session.process_events()
            sleep(POLL_INTERVAL)
        assert_loaded(spotify_object)
        return spotify_object
コード例 #5
0
ファイル: client.py プロジェクト: fldc/Spotify.bundle
    def get_starred_tracks(self):
        ''' Return the user's starred tracks

        TODO this should be made async with a callback rather than assuming
        the starred playlist is loaded (will fail if it isn't right now).
        '''
        self.log("Get starred")
        return assert_loaded(self.session.starred()) if self.session else None
コード例 #6
0
ファイル: client.py プロジェクト: jarlebh/Spotify.bundle
    def get_starred_tracks(self):
        ''' Return the user's starred tracks

        TODO this should be made async with a callback rather than assuming
        the starred playlist is loaded (will fail if it isn't right now).
        '''
        self.log("Get starred")
        return assert_loaded(self.session.starred()) if self.session else None
コード例 #7
0
 def get_playlist(self, folder_id, index):
     playlists = self.client.get_playlists(folder_id)
     if len(playlists) < index + 1:
         return MessageContainer(header=L("MSG_TITLE_PLAYLIST_ERROR"),
                                 message=L("MSG_BODY_PLAYIST_ERROR"))
     playlist = playlists[index]
     tracks = list(playlist)
     Log("Get playlist: %s", playlist.name().decode("utf-8"))
     directory = ObjectContainer(title2=playlist.name().decode("utf-8"),
                                 view_group=ViewMode.Tracks)
     for track in assert_loaded(tracks):
         self.add_track_to_directory(track, directory)
     return directory
コード例 #8
0
ファイル: plugin.py プロジェクト: jarlebh/Spotify.bundle
 def get_playlist(self, folder_id, index):
     playlists = self.client.get_playlists(folder_id)
     if len(playlists) < index + 1:
         return MessageContainer(
             header = L("MSG_TITLE_PLAYLIST_ERROR"),
             message = L("MSG_BODY_PLAYIST_ERROR")
         )
     playlist = playlists[index]
     tracks = list(playlist)
     Log("Get playlist: %s", playlist.name().decode("utf-8"))
     directory = ObjectContainer(
         title2 = playlist.name().decode("utf-8"),
         view_group = ViewMode.Tracks)
     for track in assert_loaded(tracks):
         self.add_track_to_directory(track, directory)
     return directory
コード例 #9
0
ファイル: client.py プロジェクト: fldc/Spotify.bundle
 def is_album_playable(self, album):
     ''' Check if an album can be played by a client or not '''
     assert_loaded(album)
     return album.is_available()
コード例 #10
0
ファイル: client.py プロジェクト: jarlebh/Spotify.bundle
 def is_album_playable(self, album):
     ''' Check if an album can be played by a client or not '''
     assert_loaded(album)
     return album.is_available()