|
|
@ -142,11 +142,12 @@ class GenericClient(object): |
|
|
|
|
|
|
|
def _get_torrent_hash(self, result): |
|
|
|
|
|
|
|
torrent_hash = None |
|
|
|
if result.url.startswith('magnet'): |
|
|
|
torrent_hash = re.findall('urn:btih:([\w]{32,40})', result.url)[0] |
|
|
|
if len(torrent_hash) == 32: |
|
|
|
torrent_hash = b16encode(b32decode(torrent_hash)).lower() |
|
|
|
else: |
|
|
|
elif result.content: |
|
|
|
info = bdecode(result.content)["info"] |
|
|
|
torrent_hash = sha1(bencode(info)).hexdigest() |
|
|
|
|
|
|
|