Private GIT

Skip to content
Snippets Groups Projects
Commit c65e31cf authored by Ruud's avatar Ruud
Browse files

PublicHD magnet link returns base32 encode. fix #766

parent 2d5481b8
Branches
Tags
No related merge requests found
from base64 import b32decode, b16encode
from couchpotato.core.event import addEvent from couchpotato.core.event import addEvent
from couchpotato.core.helpers.encoding import toSafeString from couchpotato.core.helpers.encoding import toSafeString
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
...@@ -48,7 +49,12 @@ class Downloader(Plugin): ...@@ -48,7 +49,12 @@ class Downloader(Plugin):
return is_correct return is_correct
def magnetToTorrent(self, magnet_link): 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 url = 'http://torrage.com/torrent/%s.torrent' % torrent_hash
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment