コード例 #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
ファイル: test.py プロジェクト: geel9/spotify-websocket-api
def album_metadata_callback(sp, album):
	print album.name+"\n"
	uris = []
	for track in album.disc[0].track:
		uris.append(SpotifyUtil.gid2uri("track", track.gid))
		sp.track_uri(SpotifyUtil.gid2id(track.gid), "mp3160", track_uri_callback)
	sp.metadata_request(uris, multi_track_metadata_callback)
コード例 #3
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
 def getImages(self):
     if self.obj != None and self.obj.attributes.picture != None:
         images = {}
         size  = 300
         image_url = Spotify.imageFromId(SpotifyUtil.gid2id(self.obj.attributes.picture), size)
         if image_url != None:
             images[size] = image_url
             return images
     return None
コード例 #4
0
 def getImages(self):
     if self.obj != None and self.obj.attributes.picture != None:
         images = {}
         size = 300
         image_url = Spotify.imageFromId(
             SpotifyUtil.gid2id(self.obj.attributes.picture), size)
         if image_url != None:
             images[size] = image_url
             return images
     return None
コード例 #5
0
ファイル: test.py プロジェクト: geel9/spotify-websocket-api
def do_next_queue(sp):
	global currentTracks, currentTrackI
	currentTrackI += 1	
	if currentTrackI >= len(currentTracks):	
		print("Done!")	
		return

	track = currentTracks[currentTrackI]

	trackId = SpotifyUtil.gid2id(track.gid)
	trackUri = SpotifyUtil.id2uri("track", trackId)

	sp.track_uri(trackId, "mp3160", track_uri_callback)
コード例 #6
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
    def imagesFromArray(image_objs, must_convert_to_id=True):
        images = {}
        for image_obj in image_objs:
            size = image_obj.width
            if size <= 60:
                size = 60
            elif size <= 160:
                size = 160
            elif size <= 300:
                size = 300
            elif size <= 320:
                size = 320
            elif size <= 640:
                size = 640

            image_id = SpotifyUtil.gid2id(image_obj.file_id) if must_convert_to_id else image_obj.file_id
            image_url = Spotify.imageFromId(image_id, size)
            if image_url != None:
                images[size] = image_url

        return images
コード例 #7
0
    def imagesFromArray(image_objs, must_convert_to_id=True):
        images = {}
        for image_obj in image_objs:
            size = image_obj.width
            if size <= 60:
                size = 60
            elif size <= 160:
                size = 160
            elif size <= 300:
                size = 300
            elif size <= 320:
                size = 320
            elif size <= 640:
                size = 640

            image_id = SpotifyUtil.gid2id(
                image_obj.file_id) if must_convert_to_id else image_obj.file_id
            image_url = Spotify.imageFromId(image_id, size)
            if image_url != None:
                images[size] = image_url

        return images
コード例 #8
0
ファイル: friendly.py プロジェクト: 10alc/Spotify2.bundle
 def getID(self):
     return SpotifyUtil.gid2id(self.obj.gid)
コード例 #9
0
 def getID(self):
     return SpotifyUtil.gid2id(self.obj.gid)