コード例 #1
0
ファイル: test.py プロジェクト: geel9/spotify-websocket-api
def track_uri_callback(sp, result):
	global currentLid, currentTracks, currentTrackI, currentPlaylistId
	if "type" in result and result["type"] == 3:
		Logging.notice("Track is not available. Skipping.")
		do_next_queue(sp)
		return

	#We need to "end" the previous track
	if currentTrackI > 0:	
		#Get the last track
		currentTrack = currentTracks[currentTrackI - 1]
		trackUri = SpotifyUtil.id2uri("track", SpotifyUtil.gid2id(currentTrack.gid))
		sp.track_end(currentLid, 0, 97, trackUri, sp.username, currentPlaylistId, None)

	currentTrack = currentTracks[currentTrackI]
	trackUri = SpotifyUtil.id2uri("track", SpotifyUtil.gid2id(currentTrack.gid))

	lid = result["lid"]
	url = result["uri"]
	currentLid = lid

	print "Got URL for: " + currentTrack.name + " - " + currentTrack.artist[0].name

	sp.track_event(lid, 3, 0, None)
	sp.track_progress(lid, 500, 97, sp.username, currentPlaylistId, trackUri, None)
	sp.track_event(lid, 4, 500, None)
	sp.send_command("sp/echo", ["h"])
	sp.send_command("sp/log", [30, 1, "heartbeat", 77, 77, 2, False])	
	time.sleep(1)
	do_next_queue(sp)
コード例 #2
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
    def parse_tunigo_genres(self, genres_json):
        genres = []
        try:

            for item_json in genres_json['items']:
                genres.append(SpotifyGenre(self, item_json['genre']))

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_genres error: " + str(e))
コード例 #3
0
    def parse_tunigo_genres(self, genres_json):
        genres = []
        try:

            for item_json in genres_json['items']:
                genres.append(SpotifyGenre(self, item_json['genre']))

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_genres error: " + str(e))
コード例 #4
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
    def parse_tunigo_albums(self, al_json):
        albums = []
        try:

            for item_json in al_json['items']:
                albums.append(item_json['release']['uri'])

            return self.objectFromURI(albums, asArray=True)

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_albums error: " + str(e))
            return albums
コード例 #5
0
    def parse_tunigo_albums(self, al_json):
        albums = []
        try:

            for item_json in al_json['items']:
                albums.append(item_json['release']['uri'])

            return self.objectFromURI(albums, asArray=True)

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_albums error: " + str(e))
            return albums
コード例 #6
0
 def getNewReleases(self):
   action       = "new-releases"
   fixed_params = "page=0&per_page=50&suppress_response_codes=1&locale=en&product=premium&version=6.31.1&platform=web"
   date_param   = "dt=" + time.strftime("%Y-%m-%dT%H:%M:%S") #2014-05-29T02%3A01%3A00"
   region_param = "region=" + self.region
   full_url = self.root_url + action + '?' + fixed_params + '&' + date_param + '&' + region_param
   
   Logging.debug("Tunigo - getNewReleases url: {}".format(full_url))
   r = requests.get(full_url)
   #Logging.debug("Tunigo - getNewReleases response: " + str(r.json()))
   Logging.debug("Tunigo - getNewReleases response OK")
   
   if r.status_code != 200 or r.headers['content-type'] != 'application/json':
     return { 'items': [] }.json()
   return r.json()
コード例 #7
0
    def getNewReleases(self):
        action = "new-releases"
        fixed_params = "page=0&per_page=50&suppress_response_codes=1&locale=en&product=premium&version=6.31.1&platform=web"
        date_param = "dt=" + time.strftime(
            "%Y-%m-%dT%H:%M:%S")  #2014-05-29T02%3A01%3A00"
        region_param = "region=" + self.region
        full_url = self.root_url + action + '?' + fixed_params + '&' + date_param + '&' + region_param

        Logging.debug("Tunigo - getNewReleases url: {}".format(full_url))
        r = requests.get(full_url)
        #Logging.debug("Tunigo - getNewReleases response: " + str(r.json()))
        Logging.debug("Tunigo - getNewReleases response OK")

        if r.status_code != 200 or r.headers[
                'content-type'] != 'application/json':
            return {'items': []}.json()
        return r.json()
コード例 #8
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
    def parse_tunigo_playlists(self, pl_json):
        playlists = []
        try:

            for item_json in pl_json['items']:
                playlist_uri  = item_json['playlist']['uri']

                uri_parts = playlist_uri.split(':')
                if len(uri_parts) < 2:
                    continue

                # TODO support playlist folders properly
                if uri_parts[1] in ['start-group', 'end-group']:
                    continue

                playlists.append(playlist_uri)

            return self.objectFromURI(playlists, asArray=True)

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_playlists error: " + str(e))
            return playlists
コード例 #9
0
    def parse_tunigo_playlists(self, pl_json):
        playlists = []
        try:

            for item_json in pl_json['items']:
                playlist_uri = item_json['playlist']['uri']

                uri_parts = playlist_uri.split(':')
                if len(uri_parts) < 2:
                    continue

                # TODO support playlist folders properly
                if uri_parts[1] in ['start-group', 'end-group']:
                    continue

                playlists.append(playlist_uri)

            return self.objectFromURI(playlists, asArray=True)

        except Exception, e:
            Logging.debug("Tunigo - parse_tunigo_playlists error: " + str(e))
            return playlists
コード例 #10
0
 def __init__(self, region = "us"):
     self.region   = region
     self.root_url = "https://api.tunigo.com/v3/space/"
     Logging.debug("Starting with Tunigo for region: {}".format(self.region))
コード例 #11
0
 def __init__(self, region="us"):
     self.region = region
     self.root_url = "https://api.tunigo.com/v3/space/"
     Logging.debug("Starting with Tunigo for region: {}".format(
         self.region))
コード例 #12
0
 def __init__(self, region="us"):
     self.region = "us" if region is None else region
     self.locale = self.getLocaleFromRegion(self.region)
     self.root_url = "http://api.tunigo.com/v3/space/"
     Logging.debug("Starting with Tunigo for region: " + self.region)
コード例 #13
0
 def doRequest(self, name, url):
     Logging.debug("Tunigo - " + name + " url: " + url)
     response = requests.get(url)
     #Logging.debug("Tunigo - " + name + " response OK")
     #Logging.debug("Tunigo - " + name + " response: " + str(response.json()))
     return response
コード例 #14
0
ファイル: tunigoapi.py プロジェクト: 10alc/Spotify2.bundle
 def __init__(self, region = "us"):
     self.region = "us" if region is None else region
     self.locale = self.getLocaleFromRegion(self.region)
     self.root_url = "http://api.tunigo.com/v3/space/"
     Logging.debug("Starting with Tunigo for region: "  + self.region)
コード例 #15
0
ファイル: tunigoapi.py プロジェクト: 10alc/Spotify2.bundle
 def doRequest(self, name, url):
   Logging.debug("Tunigo - " + name + " url: " + url)
   response = requests.get(url)
   #Logging.debug("Tunigo - " + name + " response OK")
   #Logging.debug("Tunigo - " + name + " response: " + str(response.json()))
   return response