コード例 #1
0
def skip_to(song_name, artist_name):
    if song_name is None:
        return statement(render_template("skip_to_no_song"))

    if artist_name is None:
        artist_name = ""
    best_match = api.closest_match(song_name, queue.tracks, artist_name, 0)

    if best_match is None:
        return statement(render_template("skip_to_no_match"))

    try:
        song, song_id = api.extract_track_info(best_match)
        index = queue.song_ids.index(song_id)
    except:
        return statement(render_template("skip_to_no_song_match"))

    queue.current_index = index
    stream_url = api.get_stream_url(queue.current())

    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(
            queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    speech_text = render_template("skip_to_speech_text",
                                  song=queue.current_track()['title'],
                                  artist=queue.current_track()['artist'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
コード例 #2
0
ファイル: selection.py プロジェクト: wd5gnr/geemusic
def play_playlist(playlist_name):
    # Retreve the content of all playlists in a users library
    all_playlists = api.get_all_user_playlist_contents()

    # Get the closest match
    best_match = api.closest_match(playlist_name, all_playlists)

    if best_match is None:
        return statement("Sorry, I couldn't find that playlist in your library.")

    # Add songs from the playlist onto our queue
    first_song_id = queue.reset(best_match['tracks'])

    # Get a streaming URL for the first song in the playlist
    stream_url = api.get_stream_url(first_song_id)
    try:
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    except:
        thumbnail = ""
    speech_text = "Playing songs from %s" % (best_match['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='')
コード例 #3
0
ファイル: selection.py プロジェクト: stridger/geemusic
def play_playlist(playlist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Retreve the content of all playlists in a users library
    all_playlists = api.get_all_user_playlist_contents()

    # Get the closest match
    best_match = api.closest_match(playlist_name, all_playlists)

    if best_match is None:
        return statement(render_template("play_playlist_no_match"))

    # Add songs from the playlist onto our queue
    first_song_id = queue.reset(best_match['tracks'])

    # Get a streaming URL for the first song in the playlist
    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_playlist_text",
                                  playlist=best_match['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
コード例 #4
0
def skip_to(song_name, artist_name):
    if song_name is None:
        return statement("Please say a song name to use this feature")

    if artist_name is None:
        artist_name = ""
    best_match = api.closest_match(song_name, queue.tracks, artist_name, 30)

    if best_match is None:
        return statement("Sorry, I couldn't find a close enough match.")

    try:
        song, song_id = api.extract_track_info(best_match)
        index = queue.song_ids.index(song_id)
    except:
        return statement("Sorry, I couldn't find that song in the queue")

    queue.current_index = index
    stream_url = api.get_stream_url(queue.current())

    thumbnail = api.get_thumbnail(queue.current_track())
    speech_text = "Skipping to %s by %s" % (queue.current_track()['title'],
                                            queue.current_track()['artist'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)