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
예제 #2
0
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
예제 #3
0
    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)        
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
    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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 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)
예제 #11
0
파일: playback.py 프로젝트: GemZ/spotimc
 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))
예제 #12
0
    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))
예제 #13
0
    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
예제 #14
0
    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
예제 #15
0
 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
예제 #16
0
 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
예제 #17
0
 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()
예제 #18
0
 def from_uri(uri, session):
     track_link = link.create_from_string(uri)
     track = track_link.as_track()
     return LoadTrack(track, session).run_and_wait()
예제 #19
0
 def from_uri(uri, session):
     album_link = link.create_from_string(uri)
     album = album_link.as_album()
     return album
예제 #20
0
 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"
예제 #21
0
 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"
예제 #22
0
 def from_uri(uri, session):
     track_link = link.create_from_string(uri)
     track = track_link.as_track()
     return LoadTrack(track, session).run_and_wait()