From 89bff73431e5e990a75b3d067fe0dfde532254ee Mon Sep 17 00:00:00 2001
From: Ruud <ruud@crashdummy.nl>
Date: Sat, 9 Mar 2013 18:15:06 +0100
Subject: [PATCH] Decode torrent hash for magnets also

---
 couchpotato/core/downloaders/utorrent/main.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py
index 6f290242..5953b117 100644
--- a/couchpotato/core/downloaders/utorrent/main.py
+++ b/couchpotato/core/downloaders/utorrent/main.py
@@ -39,19 +39,19 @@ class uTorrent(Downloader):
         if not filedata and data.get('type') == 'torrent':
             log.error('Failed sending torrent, no data')
             return False
+
         if data.get('type') == 'torrent_magnet':
             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)
         else:
-            # Convert base 32 to hex
-            if len(torrent_hash) == 32:
-                torrent_hash = b16encode(b32decode(torrent_hash))
-            else:
-                info = bdecode(filedata)["info"]
-                torrent_hash = sha1(bencode(info)).hexdigest().upper()
-
+            info = bdecode(filedata)["info"]
+            torrent_hash = sha1(bencode(info)).hexdigest().upper()
             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
         try:
             if not self.utorrent_api:
-- 
GitLab