本文整理汇总了Python中Core.Util.UtilBot.find_youtube_info方法的典型用法代码示例。如果您正苦于以下问题:Python UtilBot.find_youtube_info方法的具体用法?Python UtilBot.find_youtube_info怎么用?Python UtilBot.find_youtube_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.Util.UtilBot
的用法示例。
在下文中一共展示了UtilBot.find_youtube_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ytban
# 需要导入模块: from Core.Util import UtilBot [as 别名]
# 或者: from Core.Util.UtilBot import find_youtube_info [as 别名]
def ytban(bot, event, *args):
if ''.join(args) == '?':
segments = UtilBot.text_to_segments("""\
**YTBan**
Usage: /ytban <search parameters>
Purpose: Get the first result from YouTube\'s search using search parameter, then bans it!
""")
bot.send_message_segments(event.conv, segments)
else:
search_terms = " ".join(args)
youtube_info = UtilBot.find_youtube_info(search_terms)
youtube_banlist = load_json('youtube_banlist.json')
if youtube_info['item_id'] not in youtube_banlist:
youtube_banlist.append(youtube_info['item_id'])
bot.send_message(event.conv,
'Video "{title}" with ID "{id}" is now banned'.format(
title=youtube_info['item_title'], id=youtube_info['item_id']))
save_json('youtube_banlist.json', youtube_banlist)
示例2: youtube
# 需要导入模块: from Core.Util import UtilBot [as 别名]
# 或者: from Core.Util.UtilBot import find_youtube_info [as 别名]
def youtube(bot, event, *args):
Segment = hangups.ChatMessageSegment
if ''.join(args) == '?':
segments = UtilBot.text_to_segments("""\
**YouTube**
Usage: /youtube <optional: search parameter>
Purpose: Get the first result from YouTube\'s search using search parameter.
""")
bot.send_message_segments(event.conv, segments)
else:
search_terms = " ".join(args)
youtube_info = UtilBot.find_youtube_info(search_terms)
youtube_banlist = load_json('youtube_banlist.json')
if youtube_info['item_id'] in youtube_banlist:
bot.send_message(event.conv, 'Sorry, that video is banned.')
else:
bot.send_message_segments(event.conv, [hangups.ChatMessageSegment('Result:', is_bold=True),
hangups.ChatMessageSegment('\n', hangups.SegmentType.LINE_BREAK),
hangups.ChatMessageSegment(youtube_info['item_title'],
hangups.SegmentType.LINK,
link_target=youtube_info['item_url'])])