def handle_query_intent(query): if not query or 'query' in convert_errors: return question('no results found, try another search query') data = ytdl.extract_info(f"ytsearch:{query}", download=False) search_results = data['entries'] if not search_results: noresult = render_template('noresult') return question(noresult) result = search_results[0] song_name = result['title'] channel_name = result['uploader'] for format_ in result['formats']: if format_['ext'] == 'm4a': mp3_url = format_['url'] playing = render_template('playing', song_name=song_name, channel_name=channel_name) return audio(playing).play(mp3_url) return question('noresult')
def play_back_finished(): result = search_results[1] song_name = result['title'] channel_name = result['uploader'] for format_ in result['formats']: if format_['ext'] == 'm4a': mp3_url = format_['url'] playing = render_template('playing', song_name=song_name, channel_name=channel_name) return audio(playing).play(mp3_url) return question('noresult')
def handle_help_intent(): fallback = render_template('fallback') return question(fallback)
def launch(): card_title = render_template('card_title') question_text = render_template('welcome') return question(question_text).simple_card(card_title, question_text)