Пример #1
0
def restart_tracks():
    if len(queue.song_ids) == 0:
        return statement(render_template("restart_tracks_none"))

    queue.current_index = 0
    stream_url = api.get_stream_url(queue.current())
    return audio(render_template("restart_tracks_text")).play(stream_url)
Пример #2
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)
Пример #3
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)
Пример #4
0
def restart_tracks():
    if len(queue.song_ids) == 0:
        return statement("You must first play tracks to restart them")

    queue.current_index = 0
    stream_url = api.get_stream_url(queue.current())
    return audio("Restarting tracks").play(stream_url)
Пример #5
0
def start_over():
    next_id = queue.current()

    if next_id is None:
        return audio(render_template("start_over"))
    else:
        stream_url = api.get_stream_url(next_id)

        return audio().play(stream_url)
Пример #6
0
def start_over():
    next_id = queue.current()

    if next_id is None:
        return audio("There are no songs on the queue")
    else:
        stream_url = api.get_stream_url(next_id)

        return audio().play(stream_url)
Пример #7
0
def resume():
    next_id = queue.current()

    if next_id == None:
        return audio("There are no songs on the queue")
    else:
        stream_url = api.get_stream_url(next_id)

        return audio().enqueue(stream_url)
Пример #8
0
def resume():
    next_id = queue.current()

    if next_id == None:
        return audio("There are no songs on the queue")
    else:
        api = GMusicWrapper.generate_api()
        stream_url = api.get_stream_url(next_id)

        return audio().enqueue(stream_url)