Private GIT

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

Decode torrent hash for magnets also

parent cd16dddf
No related branches found
Tags
No related merge requests found
...@@ -39,19 +39,19 @@ class uTorrent(Downloader): ...@@ -39,19 +39,19 @@ class uTorrent(Downloader):
if not filedata and data.get('type') == 'torrent': if not filedata and data.get('type') == 'torrent':
log.error('Failed sending torrent, no data') log.error('Failed sending torrent, no data')
return False return False
if data.get('type') == 'torrent_magnet': if data.get('type') == 'torrent_magnet':
torrent_hash = re.findall('urn:btih:([\w]{32,40})', data.get('url'))[0].upper() torrent_hash = re.findall('urn:btih:([\w]{32,40})', data.get('url'))[0].upper()
torrent_params['trackers'] = '%0D%0A%0D%0A'.join(self.torrent_trackers) torrent_params['trackers'] = '%0D%0A%0D%0A'.join(self.torrent_trackers)
else:
# Convert base 32 to hex
if len(torrent_hash) == 32:
torrent_hash = b16encode(b32decode(torrent_hash))
else: else:
info = bdecode(filedata)["info"] info = bdecode(filedata)["info"]
torrent_hash = sha1(bencode(info)).hexdigest().upper() torrent_hash = sha1(bencode(info)).hexdigest().upper()
torrent_filename = self.createFileName(data, filedata, movie) torrent_filename = self.createFileName(data, filedata, movie)
# Convert base 32 to hex
if len(torrent_hash) == 32:
torrent_hash = b16encode(b32decode(torrent_hash))
# Send request to uTorrent # Send request to uTorrent
try: try:
if not self.utorrent_api: if not self.utorrent_api:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment