Пример #1
0
def queue_song(song_name, artist_name):
    app.logger.debug("Queuing song %s by %s" % (song_name, artist_name))

    if len(queue.song_ids) == 0:
        return statement("You must first play a song")

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Queue the track in the list of song_ids
    # queue.enqueue_track(song) //OLD
    if GMusicWrapper.use_library_first():
        song_id = song['id']
    else:
        song_id = song['storeId']
    queue.enqueue_track(song, song_id)

    stream_url = api.get_stream_url(song)
    card_text = "Queued %s by %s." % (song['title'], song['artist'])
    thumbnail = api.get_thumbnail(song)
    return audio().enqueue(stream_url) \
        .standard_card(title=card_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
Пример #2
0
def queue_song(song_name, artist_name):
    app.logger.debug("Queuing song %s by %s" % (song_name, artist_name))

    if len(queue.song_ids) == 0:
        return statement(render_template("queue_song_no_song"))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

    if song is False:
        return statement(render_template("no_song"))

    # Queue the track in the list of song_ids
    queue.enqueue_track(song)
    stream_url = api.get_stream_url(song)
    card_text = render_template("queue_song_queued",
                                song=song['title'],
                                artist=song['artist'])
    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(
            queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    return audio().enqueue(stream_url) \
        .standard_card(title=card_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail)
Пример #3
0
def play_song(song_name, artist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    app.logger.debug("Fetching song %s by %s" % (song_name, artist_name))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

    if song is False:
        return statement(render_template("no_song"))

    # Start streaming the first track
    first_song_id = queue.reset([song])
    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)
Пример #4
0
def play_song(song_name, artist_name):
    app.logger.debug("Fetching song %s by %s" % (song_name, artist_name))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Start streaming the first track
    first_song_id = queue.reset([song])
    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 %s by %s" % (song['title'], song['artist'])
    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='')
Пример #5
0
def queue_song(song_name, artist_name):
    app.logger.debug("Queuing song %s by %s" % (song_name, artist_name))

    if len(queue.song_ids) == 0:
        return statement("You must first play a song")

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Queue the track in the list of song_ids
    queue.enqueue_track(song)
    stream_url = api.get_stream_url(song)
    card_text = "Queued %s by %s." % (song['title'], song['artist'])
    try:
        thumbnail = api.get_thumbnail(song['albumArtRef'][0]['url'])
    except:
        thumbnail = ""
    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='')
Пример #6
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)
Пример #7
0
def play_song(song_name, artist_name):
    app.logger.debug("Fetching song %s by %s" % (song_name, artist_name))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Start streaming the first track
    first_song_id = queue.reset([song])
    stream_url = api.get_stream_url(first_song_id)

    speech_text = "Playing %s by %s" % (song['title'], song['artist'])
    return audio(speech_text).play(stream_url)
Пример #8
0
def queue_song(song_name, artist_name):
    app.logger.debug("Queuing song %s by %s" % (song_name, artist_name))

    if len(queue.song_ids) == 0:
        return statement("You must first play a song")

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Queue the track in the list of song_ids
    queue.enqueue_track(song)
    stream_url = api.get_stream_url(song)
    return audio().enqueue(stream_url)
Пример #9
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)
Пример #10
0
def play_song(song_name, artist_name):
    app.logger.debug(
        "Fetching song %s by %s" %
        (song_name,
         artist_name))  # TODO: fix the "song by artist" retrieval system

    # Fetch the song
    song = api.get_song(song_name, artist_name)

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

    # Start streaming the first track
    first_song_id = queue.reset([song])
    stream_url = api.get_stream_url(first_song_id)

    thumbnail = api.get_thumbnail(queue.current_track())
    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)