Esempio n. 1
0
def previous_song():
    if queue.previous:
        speech = 'playing previously played song'
        prev_stream = queue.step_back()
        dump_stream_info()
        return audio(speech).play(prev_stream)

    else:
        return audio('There are no songs in your playlist history.')
Esempio n. 2
0
def next_song():
    if queue.up_next:
        speech = 'playing next queued song'
        next_stream = queue.step()
        _infodump('Stepped queue forward to {}'.format(next_stream))
        dump_stream_info()
        return audio(speech).play(next_stream)
    else:
        return audio('There are no more songs in the queue')
Esempio n. 3
0
def pause():
    seconds = current_stream.offsetInMilliseconds / 1000
    msg = 'Paused the Playlist on track {}, offset at {} seconds'.format(
        queue.current_position, seconds)
    _infodump(msg)
    dump_stream_info()
    return audio(msg).stop().simple_card(msg)
Esempio n. 4
0
def restart_track():
    if queue.current:
        speech = 'Restarting current track'
        dump_stream_info()
        return audio(speech).play(queue.current, offset=0)
    else:
        return statement('There is no current song')
Esempio n. 5
0
def play_song(uri):
    response = subprocess.Popen(["youtube-dl", uri, "-j"], stdout=subprocess.PIPE)
    raw = json.loads(response.stdout.read())
    source = ''
    for format in raw['formats']:
        if format['ext'] == 'mp4':
            source = format['url']
    return audio().play(source)
Esempio n. 6
0
def nearly_finished():
    next_id = queue.up_next()

    if next_id is not None:
        stream_url = api.get_stream_url(next_id)

        return audio().enqueue(stream_url)
    return empty_response()
Esempio n. 7
0
def stop():
    # try:
    #     firstname = session.attributes['firstname']
    # except KeyError:
    #     firstname = 'my friend'
    # bye_message = render_template("bye", firstname=firstname)
    bye_message = render_template("bye")
    return audio(bye_message).clear_queue(stop=True)
Esempio n. 8
0
def e_dance():
    speech_text = "Model 4 says it's a dance party!"
    stream_url = 'https://archive.org/download/mc_hammer_202012_202012/mc_hammer.mp3'
    ser.write(b'd')
    client.send({'type': 'dance',
                 'foo': [1, 2, 3, 4, 5]})
    #return statement(speech_text).simple_card('Model 4', speech_text)
    return audio(speech_text).play(stream_url)
Esempio n. 9
0
 def test_custom_token(self):
     """ Check to see that the provided opaque token remains constant"""
     token = "hello_world"
     audio_item = audio()._audio_item(stream_url='https://fakestream',
                                      offset=10,
                                      opaque_token=token)
     self.assertEqual(token, audio_item['stream']['token'])
     self.assertEqual(10, audio_item['stream']['offsetInMilliseconds'])
Esempio n. 10
0
def loop_off():
    if len(queue.song_ids) == 0:
        return statement("There are no songs in the queue.")

    first_song_id = queue.loop_mode(False)
    stream_url = api.get_stream_url(first_song_id)

    return audio().enqueue(stream_url)
Esempio n. 11
0
def funky():
    logger.info('Hitting the funky intent.')
    speech = "Oh yeah... feeling funky!"
    stream_url = config['funky_music_url']
    hue_url = 'https://maker.ifttt.com/trigger/' + \
        config['funky_ifttt_url'] + '/with/key/' + config['secret_ifttt_key']
    pause_the_lights(hue_url, 1)
    return audio(speech).play(stream_url)
Esempio n. 12
0
def demo():
    speech = ("You got it bud!", "Let's get this party started",
              "Let's go amigos!", "Get ready for a good time!",
              "Awesome, I love this song!", "I'm so excited!",
              "You got it buddy")
    stream_url = 'https://ia601500.us.archive.org/34/items/DESPACITOBASSBOOSTEDdespacito2/DESPACITO%20-%20BASS%20BOOSTED%20%28despacito%202%29.mp3'
    return audio(speech[np.random.randint(0, len(speech))]).play(stream_url,
                                                                 offset=0)
Esempio n. 13
0
def loop_off():
    if len(queue.song_ids) == 0:
        return statement(render_template("loop_text"))

    first_song_id = queue.loop_mode(False)
    stream_url = api.get_stream_url(first_song_id)

    return audio().enqueue(stream_url)
Esempio n. 14
0
def nearly_finished():
    if queue.up_next:
        _infodump('Alexa is now ready for a Next or Previous Intent')
        # dump_stream_info()
        next_stream = queue.up_next
        _infodump('Enqueueing {}'.format(next_stream))
        return audio().enqueue(next_stream)
    else:
        _infodump('Nearly finished with last song in playlist')
Esempio n. 15
0
def shuffle_off():
    if len(queue.song_ids) == 0:
        return statement(render_template("shuffle_off"))

    # Start streaming the first track in the new shuffled list
    first_song_id = queue.shuffle_mode(False)
    stream_url = api.get_stream_url(first_song_id)

    return audio().enqueue(stream_url)
Esempio n. 16
0
def _play_track(idx):
    print('play track index #%d' % idx)
    t = tracks[idx]
    url = t['urls'][0].replace('http', 'https')
    url = url.replace('s3.castbox.fm', 'd1asnxkov2i2k7.cloudfront.net')
    title = t['title']
    print('url = %s' % url)
    resp = audio('RoboTalk. %s' % title).play(url)
    return resp
Esempio n. 17
0
def nearly_finished():
    redis_conn = get_redis_conn_pool()
    queue_key = REMIX_QUEUE_PREFIX
    next_stream = redis_conn.lpop(queue_key)
    if next_stream:
        _infodump("发现下一个播放队列")
        return audio().enqueue(next_stream)
    else:
        _infodump('Nearly finished with last reminx in playlist')
Esempio n. 18
0
def nearly_finished():
    if queue.up_next:
        _infodump('Alexa is now ready for a Next or Previous Intent')
        # dump_stream_info()
        next_stream = queue.up_next
        _infodump('Enqueueing {}'.format(next_stream))
        return audio().enqueue(next_stream)
    else:
        _infodump('Nearly finished with last song in playlist')
Esempio n. 19
0
def shuffle_on():
    if len(queue.song_ids) == 0:
        return statement("There are no songs to shuffle.")

    # Start streaming the first track in the new shuffled list
    first_song_id = queue.shuffle_mode(True)
    stream_url = api.get_stream_url(first_song_id)

    return audio().enqueue(stream_url)
Esempio n. 20
0
def play_audio(guest_artist):
    session.attributes['guest_artist'] = guest_artist
    artist_request = guest_artist
    stream_url = get_url(artist_request)
    if not stream_url:
        no_result = render_template('no result', guest_artist=guest_artist)
        return question(no_result)
    speech = "Here's one of my favorites"
    return audio(speech).play(stream_url, offset=0)
Esempio n. 21
0
def play_artist_radio(artist_name):
    # TODO: Handle track duplicates?
    tracks = api.get_station_tracks("IFL")

    # Get a streaming URL for the first song
    first_song_id = queue.reset(tracks)
    stream_url = api.get_stream_url(first_song_id)

    speech_text = "Playing music from your personalized station"
    return audio(speech_text).play(stream_url)
Esempio n. 22
0
def playRandomAudio():
    # get welcome message from template
    if request["locale"] == "es-MX":
        speech = render_template('welcome_message_es')
    else:
        speech = render_template('welcome_message_en')
    logger.debug("speech: " + speech)
    # play a random audio file from my S3 bucket
    stream_url = getRandomAudio(s3, logger)
    return audio(speech).play(stream_url)
Esempio n. 23
0
def chileNews():
    # get welcome message from template
    if request["locale"] == "es-MX":
        speech = render_template('welcome_message_es')
    else:
        speech = render_template('welcome_message_en')
    logger.debug("speech: " + speech)
    # play latest newsflash from feed
    stream_url = getTodayNews()
    return audio(speech).play(stream_url)
Esempio n. 24
0
def stop():
    """
    This method handles Alexa skill stop and cancel requests
    :return: json for response for Alexa
    """
    try:
        return audio('Stopping').clear_queue(stop=True)
    except Exception as err:
        logging.error(err)
        return statement('Nothing to stop or cancel.')
Esempio n. 25
0
def resume():
    """
    This method handles Alexa skill resume requests
    :return: json for response for Alexa
    """
    try:
        return audio('Resuming.').resume()
    except Exception as err:
        logging.error(err)
        return statement('Nothing to resume.')
Esempio n. 26
0
def resume():
    """
    This method handles Alexa skill start over requests
    :return: json for response for Alexa
    """
    try:
        return audio('Starting over.').start_over()
    except Exception as err:
        logging.error(err)
        return statement('Nothing to start over.')
Esempio n. 27
0
def stop_audio():
    """
    This method handles Alexa skill pause requests
    :return: json for response for Alexa
    """
    try:
        return audio('Ok, pausing the audio').stop()
    except Exception as err:
        logging.error(err)
        return statement('Nothing to pause.')
Esempio n. 28
0
def play():
    feedurl = 'http://feeds.lds.org/ScriptureStories'
    parsed = podcastparser.parse(feedurl, urllib.request.urlopen(feedurl))
    episode = random.choice(parsed['episodes'])
    url = episode['enclosures'][0]['url']
    url = requests.get(url, allow_redirects=False).headers['location']
    url = url.replace('http', 'https')
    speech = f"Playing Scripture Story {episode['title']}"
    _infodump(f"{speech} ({url})")
    return audio(speech).play(url)  #, offset=93000)
Esempio n. 29
0
def launch():
    text = 'Welcome to See Be See Radio (Unofficial).'
    prompt = 'For example say, play Radio One Edmonton'
    '''
    return question(text).reprompt(prompt) \
        .simple_card(title='Welcome to CBC Radio (Unofficial)',
                     content='Try asking me to play a station')
    '''
    return audio(text).play(
        'https://cbcliveradio-lh.akamaihd.net/i/CBCR1_EDM@372985/master.m3u8')
Esempio n. 30
0
def search_immediately_term(lied):
    audio().stop()
    term = lied.replace("for", "")
    term = term.replace("search", "")
    term = term.strip()

    s = { 'search_query':term.encode('utf-8') }
    raw = urllib2.urlopen('https://www.youtube.com/results?'+urllib.urlencode(s))
    html = BeautifulSoup(raw, "html.parser")

    videos = html.findAll(match_class(["yt-lockup-title"]))

    res = []

    for video in videos:
        link = video.findAll('a')[0]
        res.append([link.text, link['href']])

    return play_song('https://www.youtube.com'+str(res[0][1]))
Esempio n. 31
0
def nearly_finished():
    ssconn.scrobble(queue.current)
    if queue.up_next:
        _infodump('Alexa is now ready for a Next or Previous Intent')
        # dump_stream_info()
        next_stream = sauth.getStreamUrl(queue.up_next)
        _infodump('Enqueueing {}'.format(next_stream))
        return audio().enqueue(next_stream)
    else:
        _infodump('Nearly finished with last song in playlist')
Esempio n. 32
0
def random_song_intent():
    """
    Alexa plays the random audio from the playlist
    """
    speech = 'Here is a random song from the playlist.'
    _infodump("random")
    x = random.randrange(0, 5)
    stream_url = random_song()
    _infodump(stream_url)
    return audio(speech).play(stream_url)
Esempio n. 33
0
def shuffle_off():
    if len(queue.song_ids) == 0:
        return statement("There are no songs to unshuffle.")
    api = GMusicWrapper.generate_api()

    # Start streaming the first track in the new shuffled list
    first_song_id = queue.shuffle_mode(False)
    stream_url = api.get_stream_url(first_song_id)

    return audio().enqueue(stream_url)
Esempio n. 34
0
def nearly_finished():
    with open('playlist.json', 'r') as file:
        f = json.loads(file.read())
        response = subprocess.Popen(["youtube-dl", f[f[0][0]+1][1], "-j"], stdout=subprocess.PIPE)
        raw = json.loads(response.stdout.read())
        source = ''
        for format in raw['formats']:
            if format['ext'] == 'mp4':
                source = format['url']
        return audio().enqueue(source)
Esempio n. 35
0
def play_library():
    if api.is_indexing():
        return statement("Please wait for your tracks to finish indexing")

    tracks = api.library.values()
    first_song_id = queue.reset(tracks)
    first_song_id = queue.shuffle_mode(True)
    stream_url = api.get_stream_url(first_song_id)

    speech_text = "Playing music from your library"
    return audio(speech_text).play(stream_url)
Esempio n. 36
0
def start_playlist():
    speech = 'Heres a playlist of some sounds. You can ask me Next, Previous, or Start Over'
    stream_url = queue.start()
    return audio(speech).play(stream_url)
Esempio n. 37
0
 def test_token_generation(self):
     """ Confirm we get a new token when setting a stream url """
     audio_item = audio()._audio_item(stream_url='https://fakestream', offset=123)
     self.assertEqual(36, len(audio_item['stream']['token']))
     self.assertEqual(123, audio_item['stream']['offsetInMilliseconds'])
Esempio n. 38
0
 def custom_token_intents():
     return audio('playing with custom token').play(self.stream_url, 
                                                    opaque_token=self.custom_token)
Esempio n. 39
0
 def play():
     return audio('playing').play(self.stream_url)
Esempio n. 40
0
def stop():
    return audio('stopping').clear_queue(stop=True)
Esempio n. 41
0
def resume():
    return audio('Resuming.').resume()
Esempio n. 42
0
def pause():
    return audio('Paused the stream.').stop()
Esempio n. 43
0
def george_michael():
    speech = 'yeah you got it!'
    stream_url = 'https://ia800203.us.archive.org/27/items/CarelessWhisper_435/CarelessWhisper.ogg'
    return audio(speech).play(stream_url)
Esempio n. 44
0
def demo():
    speech = "Here's one of my favorites"
    stream_url = 'https://www.vintagecomputermusic.com/mp3/s2t9_Computer_Speech_Demonstration.mp3'
    return audio(speech).play(stream_url, offset=93000)
Esempio n. 45
0
 def test_custom_token(self):
     """ Check to see that the provided opaque token remains constant"""
     token = "hello_world"
     audio_item = audio()._audio_item(stream_url='https://fakestream', offset=10, opaque_token=token)
     self.assertEqual(token, audio_item['stream']['token'])
     self.assertEqual(10, audio_item['stream']['offsetInMilliseconds'])