本文整理匯總了Python中mega.Mega.get_public_url_info方法的典型用法代碼示例。如果您正苦於以下問題:Python Mega.get_public_url_info方法的具體用法?Python Mega.get_public_url_info怎麽用?Python Mega.get_public_url_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mega.Mega
的用法示例。
在下文中一共展示了Mega.get_public_url_info方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: BotModule
# 需要導入模塊: from mega import Mega [as 別名]
# 或者: from mega.Mega import get_public_url_info [as 別名]
class BotModule(object):
def __init__(self, storage):
self.storage = storage
self.admins = {}
self.bot = None
sys.stdout.write(' (logging in to mega.co.nz) ')
self.mega = Mega({'verbose': True})
self.mega.login_anonymous()
def event(self, ev):
if ev['name'] == 'msg':
split = ev['msg'].split(' ')
for word in split:
if (word.lower().find('https://mega.co.nz/#!') == 0) or (word.lower().find('http://mega.co.nz/#!') == 0):
try:
info = self.mega.get_public_url_info(word)
assert(info.get('name') != None)
assert(info.get('size') != None)
except Exception, e:
ev['to'].msg('There was an error fetching Mega info from that link, it may be private or there may have happened a communication error. Sorry.')
return
ev['to'].msg(chr(3)+ '5Mega| ' + chr(15) +chr(2) + info['name'] + chr(15) + ' [' + fmt(info['size']) + ']')