本文整理匯總了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'])])