def get_next_track(sess_obj): next_trackid = xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)") if next_trackid: #Try loading it as a spotify track link_obj = link.create_from_string("spotify:track:%s" %next_trackid) if link_obj: return load_track(sess_obj, link_obj.as_track()) #Try to parse as a local track link_obj = link.create_from_string("spotify:local:%s" %next_trackid) if link_obj: local_track = link_obj.as_track() return load_track(sess_obj, local_track.get_playable(sess_obj)) else: return None
def get_next_track(sess_obj): next_trackid = xbmc.getInfoLabel( "MusicPlayer.(1).Property(spotifytrackid)") if next_trackid: #Try loading it as a spotify track link_obj = link.create_from_string("spotify:track:%s" % next_trackid) if link_obj: return load_track(sess_obj, link_obj.as_track()) #Try to parse as a local track link_obj = link.create_from_string("spotify:local:%s" % next_trackid) if link_obj: local_track = link_obj.as_track() return load_track(sess_obj, local_track.get_playable(sess_obj)) else: return None
def playlist_tracks(self, page = {}): page = Page.from_obj(page) playlist_link = link.create_from_string(page.identifier) session = self.current_session() linked_playlist = Playlist(playlist.create(session, playlist_link)) return self.tracks_model(linked_playlist, page, session)
def artist_albums(self, artist_uri): session = self.current_session() artist = link.create_from_string(artist_uri).as_artist() browse = BrowseArtist(artist, session).run_and_wait() albums = AlbumFilter(browse.albums()).filter() return self.model_factory.to_album_list_model(albums)
def do_set_starred(self, line): track_ids = line.split(',') track_list = [] for item in track_ids: link_obj = link.create_from_string(item) track_list.append(link_obj.as_track()) track.set_starred(self._session, track_list, True)
def _get_track_object(self, track_str): #Strip the optional extension... r = re.compile('\.wav$', re.IGNORECASE) track_id = re.sub(r, '', track_str) #Try to parse as a track link_obj = link.create_from_string("spotify:track:%s" % track_id) if link_obj is not None: track_obj = link_obj.as_track() load_track(self.__session, track_obj) return track_obj #Try to parse as a local track link_obj = link.create_from_string("spotify:local:%s" % track_id) if link_obj is not None: track_obj = link_obj.as_track() load_track(self.__session, track_obj) return track_obj #Fail if we reach this point raise cherrypy.HTTPError(404)
def do_share(self, line): args = line.split(' ', 2) to_user = args[0] track_ids = args[1].split(',') message = args[2] track_list = [] for item in track_ids: link_obj = link.create_from_string(item) track_list.append(link_obj.as_track()) self._do_inboxpost(to_user, track_list, message) print "%d track(s) where sent successfully to '%s" % (len(track_list), to_user)
def _get_track_from_url(self, sess_obj, url): #Get the clean track if from the url path = urlparse(url).path r = re.compile('^/track/(.+?)(?:\.wav)?$', re.IGNORECASE) mo = r.match(path) #If we succeed, create the object if mo is not None: #Try loading it as a spotify track link_obj = link.create_from_string("spotify:track:%s" % mo.group(1)) if link_obj is not None: return load_track(sess_obj, link_obj.as_track()) #Try to parse as a local track link_obj = link.create_from_string("spotify:local:%s" % mo.group(1)) if link_obj is not None: #return the autolinked one, instead of the local track local_track = link_obj.as_track() return load_track(sess_obj, local_track.get_playable(sess_obj))
def _get_track_from_url(self, sess_obj, url): #Get the clean track if from the url path = urlparse(url).path r = re.compile('^/track/(.+?)(?:\.wav)?$', re.IGNORECASE) mo = r.match(path) #If we succeed, create the object if mo is not None: #Try loading it as a spotify track link_obj = link.create_from_string("spotify:track:{0}".format( mo.group(1))) if link_obj is not None: return load_track(sess_obj, link_obj.as_track()) #Try to parse as a local track tmpStr = "spotify:local:{0}".format(mo.group(1)) link_obj = link.create_from_string(tmpStr) if link_obj is not None: #return the autolinked one, instead of the local track local_track = link_obj.as_track() return load_track(sess_obj, local_track.get_playable(sess_obj))
def _load_artist(self, id): full_id = "spotify:artist:%s" % id checker = BulkConditionChecker() #Get the artist object link_obj = link.create_from_string(full_id) artist_obj = link_obj.as_artist() #Now initialize the artistbrowse load stuff callbacks = ArtistbrowseLoadCallbacks(checker) artistbrowse_obj = artistbrowse.Artistbrowse(self._session, artist_obj, callbacks) checker.add_condition(artistbrowse_obj.is_loaded) checker.complete_wait(10) return artist_obj, artistbrowse_obj
def _load_album(self, id): import time full_id = "spotify:album:%s" % id checker = BulkConditionChecker() #All the album loading stuff link_obj = link.create_from_string(full_id) album_obj = link_obj.as_album() #Now the albumbrowse object callbacks = AlbumbrowseLoadCallbacks(checker) albumbrowse_obj = albumbrowse.Albumbrowse(self._session, album_obj, callbacks) checker.add_condition(albumbrowse_obj.is_loaded) checker.complete_wait(10) return album_obj, albumbrowse_obj
def _load_artist(self, id): full_id = "spotify:artist:%s" % id checker = BulkConditionChecker() #Get the artist object link_obj = link.create_from_string(full_id) artist_obj = link_obj.as_artist() #Now initialize the artistbrowse load stuff callbacks = ArtistbrowseLoadCallbacks(checker) artistbrowse_obj = artistbrowse.Artistbrowse( self._session, artist_obj, callbacks ) checker.add_condition(artistbrowse_obj.is_loaded) checker.complete_wait(10) return artist_obj, artistbrowse_obj
def _load_album(self, id): import time full_id = "spotify:album:%s" % id checker = BulkConditionChecker() #All the album loading stuff link_obj = link.create_from_string(full_id) album_obj = link_obj.as_album() #Now the albumbrowse object callbacks = AlbumbrowseLoadCallbacks(checker) albumbrowse_obj = albumbrowse.Albumbrowse( self._session, album_obj, callbacks ) checker.add_condition(albumbrowse_obj.is_loaded) checker.complete_wait(10) return album_obj, albumbrowse_obj
def startTrack(self, stream, trackId): with self.trackLock: try: Log("playback starting: %s"%(trackId)) self.endTrack_Internal() self.stream = stream link_obj = link.create_from_string("spotify:track:%s" % trackId) if link_obj is not None: track_obj = link_obj.as_track() self.track = load_track(self.session, track_obj) self.status = PlaybackStatus.Streaming self.firstFrame = True self.session.player_load(track_obj) self.session.player_play(True) Log("playback started: %s"%(trackId)) del link_obj del track_obj except Exception as e: Log("Playback Service: Error Starting Track %s"%(e)) self.endTrack_Internal()
def from_uri(uri, session): track_link = link.create_from_string(uri) track = track_link.as_track() return LoadTrack(track, session).run_and_wait()
def from_uri(uri, session): album_link = link.create_from_string(uri) album = album_link.as_album() return album
def do_link(self, line): lo = link.create_from_string(line) if lo is not None: print "link parsed OK" else: print "failed parsing link"