Functions.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Personal_AI_Assistant 作者: PratylenClub 项目源码 文件源码
def play_podcast(assistant, player_vlc, instance_vlc, podcast_dic, podcast_index=None):
    assistant.speak("Tell me the name of the podcast")
    msg = assistant.active_listen()
    if msg in podcast_dic.keys():
        rss = podcast_dic[msg]
    else:
        rss = DEFAULT_PODCAST
    assistant.speak("There you go!")
    res = feedparser.parse(rss)
    number_records_in_feed = len(res.entries)
    if podcast_index is None:
        podcast_index = random.randint(0,len(res.entries) - 1)
    if number_records_in_feed < podcast_index:
        podcast_index = number_records_in_feed
    href = ""
    for link in res.entries[podcast_index].links:
        if ".mp3" in link.href:
            href = link.href
            break
    if href != "":
        media = instance_vlc.media_new(href)
        player_vlc.set_media(media)
        player_vlc.play()
    else:
        assistant.speak("I am sorry, but the podcast requested is not available!")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号