Esempio n. 1
0
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)
Esempio n. 2
0
def play_artist_radio(name):
    if str(environ['USE_LIBRARY_FIRST']) is True:
        # return statement("Sorry, artist radios aren't currently supported at the moment.")
        return None
# Fetch the artist
    artist = api.get_artist(name)

    if artist is False:
        return statement("Sorry, I couldn't find that artist")

# station_id = api.get_station("%s Radio" % artist['name'], artist_id=artist['artistId'])
    station_id = api.get_station("%s Radio" % artist['name'],
                                 artist_id=artist['artistId'])

    #if str(environ['USE_LIBRARY_FIRST']) is True:
    #_station_info = api.get_station_info(station_id, 999) # 999 is the maximium number of tracks to return. I will set it to a lower amount should this cause some lag...

    # TODO: Handle track duplicates (this may be possible using session ids)
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)
    #if str(enviorn['USE_LIBRARY_FIRST']) is True:
    # Get a radio station for free accounts
    #stream_url = api.get_station_track_stream_url(first_song_id, _station_info.get('wentryid', None), _station_info.get('sessionToken', None))
    #else:
    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    thumbnail = api.get_thumbnail(artist)
    speech_text = "Playing %s radio" % artist['name']
    return audio(speech_text).play(stream_url) \
           .standard_card(title=speech_text,
                          text='',
                          small_image_url=thumbnail,
                          large_image_url=thumbnail)
Esempio n. 3
0
def play_artist_radio(artist_name):
    # TODO -- can we do this without a subscription?
    if not api.use_store:
        return statement(render_template("not_supported_without_store"))

    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(render_template("no_artist"))

    station_id = api.get_station("%s Radio" % artist['name'],
                                 artist_id=artist['artistId'])
    # TODO: Handle track duplicates (this may be possible using session ids)
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)

    # Get a streaming URL for the top song
    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_artist_radio_text",
                                  artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
Esempio n. 4
0
def play_artist(artist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(
            render_template("play_artist_none", artist=artist_name))

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    if "artistArtRef" in artist:
        thumbnail = api.get_thumbnail(artist['albumArtRef'])
    else:
        thumbnail = None
    if api.use_store:
        speech_text = render_template("play_artist_text",
                                      artist=artist['name'])
    else:
        speech_text = render_template("play_artist_text_library",
                                      artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
Esempio n. 5
0
def play_artist_radio(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)
    app.logger.debug("Fetching artist %s" % artist_name)

    if artist is False:
        return statement(render_template("no_artist"))

    station_id = api.get_station("%s Radio" % artist['name'],
                                 artist_id=artist['artistId'])
    # TODO: Handle track duplicates (this may be possible using session ids)
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    thumbnail = None
    speech_text = render_template("play_artist_radio_text",
                                  artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
Esempio n. 6
0
def play_artist(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement("Sorry, I couldn't find that artist")

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)
    try:
        thumbnail = api.get_thumbnail(artist['artistArtRef'])
    except:
        thumbnail = ""
    speech_text = "Playing top tracks by %s" % artist['name']
    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='')
Esempio n. 7
0
def play_artist_radio(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement("Sorry, I couldn't find that artist")

    station_id = api.get_station("%s Radio" %
                                 artist['name'], artist_id=artist['artistId'])
    # TODO: Handle track duplicates (this may be possible using session ids)
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    try:
        thumbnail = api.get_thumbnail(artist['artistArtRef'])
    except:
        thumbnail = ""
    speech_text = "Playing %s radio" % artist['name']
    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='')
Esempio n. 8
0
def play_artist(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement("Sorry, I couldn't find that artist")
    
    #api.get_artist found somthing from store api search 
    if 'topTracks' in artist:
        # Setup the queue
        first_song_id = queue.reset(artist['topTracks'])
        nameKey = 'name'
        trackType = 'top'
        
    else: #api.get_artist searched the uploaded library instead, artist is a list
        shuffle(artist)
        first_song_id = queue.reset(artist)
        #make artist just the first value in the dictionary for the rest of this function
        artist = artist[0]
        nameKey = 'artist'
        trackType = 'random library'

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    thumbnail = api.get_thumbnail(artist)
    speech_text = "Playing %s tracks by %s" % (trackType, artist[nameKey])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                        text='',
                        small_image_url=thumbnail,
                        large_image_url=thumbnail)
Esempio n. 9
0
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)
Esempio n. 10
0
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)
Esempio n. 11
0
def play_artist(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist == False:
        return statement("Sorry, I couldn't find that artist")

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    speech_text = "Playing top tracks from %s" % artist['name']
    return audio(speech_text).play(stream_url)
Esempio n. 12
0
def play_artist(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(render_template("play_artist_none"))

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    #thumbnail = api.get_thumbnail(artist['artistArtRef'])
    speech_text = render_template("play_artist_text", artist=artist['name'])
    return audio(speech_text).play(stream_url)  #\
Esempio n. 13
0
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)
Esempio n. 14
0
def play_artist_radio(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist == False:
        return statement("Sorry, I couldn't find that artist")

    station_id = api.get_station("%s Radio" % artist['name'],
                                 artist_id=artist['artistId'])
    # TODO: Handle track duplicates
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    speech_text = "Playing %s radio" % artist['name']
    return audio(speech_text).play(stream_url)
Esempio n. 15
0
def play_artist(artist_name):
    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(render_template("play_artist_none", artist=artist_name))

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    thumbnail = api.get_thumbnail(artist['artistArtRef'])
    speech_text = render_template("play_artist_text", artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)