def play_song_radio(song_name, artist_name, album_name): app.logger.debug("Fetching song %s by %s from %s" % (song_name, artist_name, album_name)) # Fetch the song song = api.get_song(song_name, artist_name, album_name) if artist_name is not None: artist = api.get_artist(artist_name) else: artist = api.get_artist(song['artist']) if album_name is not None: album = api.get_album(album_name) else: album = api.get_album(song['album']) if song is False: return statement("Sorry, I couldn't find that song") station_id = api.get_station("%s Radio" % song['title'], track_id=song['storeId'], artist_id=artist['artistId'], album_id=album['albumId']) tracks = api.get_station_tracks(station_id) first_song_id = queue.reset(tracks) stream_url = api.get_stream_url(first_song_id) thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url']) speech_text = "Playing %s by %s" % (song['title'], song['artist']) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_album(album_name, artist_name): if not api.use_store and api.is_indexing(): return statement(render_template("indexing")) app.logger.debug("Fetching album %s" % album_name) # Fetch the album album = api.get_album(album_name, artist_name) if album is False: return statement(render_template("no_album")) # Setup the queue first_song_id = queue.reset(album['tracks']) # Start streaming the first track stream_url = api.get_stream_url(first_song_id) if "albumArtRef" in album: thumbnail = api.get_thumbnail(album['albumArtRef']) else: thumbnail = None speech_text = render_template("play_album_text", album=album['name'], artist=album['albumArtist']) app.logger.debug(speech_text) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_album(album_name, artist_name): app.logger.debug("Fetching album %s by %s" % (album_name, artist_name)) # Fetch the album album = api.get_album(album_name, artist_name) if album is False: return statement("Sorry, I couldn't find that album") # Setup the queue first_song_id = queue.reset(album['tracks']) # Start streaming the first track stream_url = api.get_stream_url(first_song_id) try: thumbnail = api.get_thumbnail(album['albumArtRef']) except: thumbnail = "" speech_text = "Playing album %s by %s" % \ (album['name'], album['albumArtist']) if (thumbnail==""): return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail) else: return audio(speech_text).play(stream_url) \ .simple_card(title=speech_text, content='')
def play_album(album_name, artist_name): app.logger.debug("Fetching album %s by %s" % (album_name, artist_name)) # Fetch the album album = api.get_album(album_name, artist_name) if album is False: return statement("Sorry, I couldn't find that album") #store dict if type(album) is dict: # Setup the queue first_song_id = queue.reset(album['tracks']) albumNameKey = 'name' else: #library list first_song_id = queue.reset(sorted(album, key=lambda record: record['trackNumber'])) #make artist just the first value in the dictionary for the rest of this function album = album[0] albumNameKey = 'album' # Start streaming the first track stream_url = api.get_stream_url(first_song_id) thumbnail = api.get_thumbnail(album) speech_text = "Playing album %s by %s" % \ (album[albumNameKey], album['albumArtist']) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_similar_song_radio(): if len(queue.song_ids) == 0: return statement("Please play a song to start radio") if api.is_indexing(): return statement("Please wait for your tracks to finish indexing") # Fetch the song song = queue.current_track() artist = api.get_artist(song['artist']) album = api.get_album(song['album']) app.logger.debug("Fetching songs like %s by %s from %s" % (song['title'], artist['name'], album['name'])) if song is False: return statement("Sorry, I couldn't find that song") station_id = api.get_station("%s Radio" % song['title'], track_id=song['storeId'], artist_id=artist['artistId'], album_id=album['albumId']) tracks = api.get_station_tracks(station_id) first_song_id = queue.reset(tracks) stream_url = api.get_stream_url(first_song_id) thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url']) speech_text = "Playing %s by %s" % (song['title'], song['artist']) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_song_radio(song_name, artist_name, album_name): if not api.use_store and api.is_indexing(): return statement(render_template("indexing")) app.logger.debug("Fetching song %s by %s from %s." % (song_name, artist_name, album_name)) # Fetch the song song = api.get_song(song_name, artist_name, album_name) if song is False: return statement(render_template("no_song")) if artist_name is not None: artist = api.get_artist(artist_name) else: artist = api.get_artist(song['artist']) if album_name is not None: album = api.get_album(album_name) else: album = api.get_album(song['album']) station_id = api.get_station("%s Radio" % song['title'], track_id=song['storeId'], artist_id=artist['artistId'], album_id=album['albumId']) tracks = api.get_station_tracks(station_id) first_song_id = queue.reset(tracks) stream_url = api.get_stream_url(first_song_id) if "albumArtRef" in queue.current_track(): thumbnail = api.get_thumbnail( queue.current_track()['albumArtRef'][0]['url']) else: thumbnail = None speech_text = render_template("play_song_text", song=song['title'], artist=song['artist']) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_similar_song_radio(): # TODO -- can we do this without a subscription? if not api.use_store: return statement(render_template("not_supported_without_store")) if len(queue.song_ids) == 0: return statement(render_template("play_similar_song_radio_no_song")) if api.is_indexing(): return statement(render_template("indexing")) # Fetch the song song = queue.current_track() artist = api.get_artist(song['artist']) album = api.get_album(song['album']) app.logger.debug("Fetching songs like %s by %s from %s" % (song['title'], artist['name'], album['name'])) if song is False: return statement(render_template("no_song")) station_id = api.get_station("%s Radio" % song['title'], track_id=song['storeId'], artist_id=artist['artistId'], album_id=album['albumId']) tracks = api.get_station_tracks(station_id) first_song_id = queue.reset(tracks) stream_url = api.get_stream_url(first_song_id) if "albumArtRef" in queue.current_track(): thumbnail = api.get_thumbnail( queue.current_track()['albumArtRef'][0]['url']) else: thumbnail = None speech_text = render_template("play_song_radio_text", song=song['title'], artist=song['artist']) return audio(speech_text).play(stream_url) \ .standard_card(title=speech_text, text='', small_image_url=thumbnail, large_image_url=thumbnail)
def play_album(album_name, artist_name): app.logger.debug("Fetching album %s by %s" % (album_name, artist_name)) # Fetch the album album = api.get_album(album_name, artist_name=artist_name) if album == False: return statement("Sorry, I couldn't find that album") # Setup the queue first_song_id = queue.reset(album['tracks']) # Start streaming the first track stream_url = api.get_stream_url(first_song_id) speech_text = "Playing album %s by %s" % (album['name'], album['albumArtist']) return audio(speech_text).play(stream_url)