Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
    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
Exemple #4
0
    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
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #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
Exemple #8
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
Exemple #9
0
 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()
Exemple #10
0
 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()