def hash_from_magnet(m):
res=Cache.magnet_re.search(m)
if res:
ih=res.group(1).upper()
if len(ih)==40 and Cache.hexa_chars.match(ih):
return res.group(1).upper()
elif len(ih)==32:
s=base64.b32decode(ih)
return "".join("{:02X}".format(ord(c)) for c in s)
else:
raise ValueError('Not BT magnet link')
else:
raise ValueError('Not BT magnet link')
评论列表
文章目录