From c65e31cfba059161ee887d1818c74bad64fef5de Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 28 Aug 2012 22:18:40 +0200 Subject: [PATCH] PublicHD magnet link returns base32 encode. fix #766 --- couchpotato/core/downloaders/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/downloaders/base.py b/couchpotato/core/downloaders/base.py index c910edd2..76f8cdff 100644 --- a/couchpotato/core/downloaders/base.py +++ b/couchpotato/core/downloaders/base.py @@ -1,3 +1,4 @@ +from base64 import b32decode, b16encode from couchpotato.core.event import addEvent from couchpotato.core.helpers.encoding import toSafeString from couchpotato.core.logger import CPLog @@ -48,7 +49,12 @@ class Downloader(Plugin): return is_correct def magnetToTorrent(self, magnet_link): - torrent_hash = re.findall('urn:btih:([\w]{40})', magnet_link)[0] + torrent_hash = re.findall('urn:btih:([\w]{32,40})', magnet_link)[0] + + # Convert base 32 to hex + if len(torrent_hash) == 32: + torrent_hash = b16encode(b32decode(torrent_hash)) + url = 'http://torrage.com/torrent/%s.torrent' % torrent_hash try: