Beispiel #1
0
def smoove():
	songs = abcdigapi._parse_input()
	song = songs[0]
	itunes_url = abcdigapi._craft_itunes_url(song["artistName"])
	return render_template('abcdigapi.html', REFRESH_INTERVAL=abcdigapi.REFRESH_INTERVAL, title=song["title"], artistName=song["artistName"],albumName=song["albumName"],dateCopyrighted=song["dateCopyrighted"],publisher=song["publisher"],itunes_url=itunes_url)
Beispiel #2
0
	
	# sometimes the ABC API doesn't refresh in a timeley matter, this check makes sure we are getting new
	#  track information.  If not, wait, then try again.
	if current_song["trackId"] == previous_song_track_id:
		# then this isn't a new song.  we need to wait awhile and break the while iteration and try again
		print "   we didn't get new song info, sleeping %s seconds" % (settings.sleep_after_no_new_track_info)
		time.sleep(settings.sleep_after_no_new_track_info)
		abc_miss_count = abc_miss_count + 1
		continue
	else:
		# this is a new song, so we need to forget the old one ..
		previous_song_track_id = current_song["trackId"]
		abc_hit_count = abc_hit_count + 1

	# GRAB EXTERNAL DATA IF WE'VE BEEN CONFIGURED TO
	if settings.display_itunes_url is True: current_song_itunes_url = abcdigapi._craft_itunes_url(current_song["artistName"])
	if settings.display_itunes_url is True: current_song_wikipedia_url = abcdigapi._craft_wikipedia_url(current_song["artistName"])
		
	# WORK OUT WHEN WE SHOULD GO AHEAD AND GET MORE DATA FROM THE ABC
	#	we do that by getting the start time of the next_song, and subtracting it from the time now.
	#	if WE GET A NEGATIVE VALUE HERE it means the song should have started already but hasn't.
	#	this is an instance of THE_EARLY_BUG.  
	#	we fix that by ..?
	next_song_starting_in_seconds_countdown = (next_song["playedTime"]-time.time()) + settings.transmission_delay
	if next_song_starting_in_seconds_countdown < 0: 				
		print " ..next_song_starting_in_seconds_countdown = %s" % next_song_starting_in_seconds_countdown
			
	# SOMETIMES WE GET INCORRECT NEXT_SONG START TIME FROM ABC.  Let's call this THE_EARLY_BUG
	#	Usually far too soon. eg;
	#		the current song started at say 08:30:00, with a duration of 350 seconds.
	#		the next song will start at say 08:30:23.