From 48db4c8b8efe585eff2de249cb1370e28a6a8cc2 Mon Sep 17 00:00:00 2001 From: Dean Gardiner Date: Sun, 29 Sep 2013 23:21:53 +1300 Subject: [PATCH] Updated rtorrent-python library --- libs/rtorrent/__init__.py | 6 ++---- libs/rtorrent/lib/torrentparser.py | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/rtorrent/__init__.py b/libs/rtorrent/__init__.py index d19c78b..b6ff73a 100755 --- a/libs/rtorrent/__init__.py +++ b/libs/rtorrent/__init__.py @@ -71,12 +71,10 @@ class RTorrent: def _verify_conn(self): # check for rpc methods that should be available - assert {"system.client_version", - "system.library_version"}.issubset(set(self._get_rpc_methods())),\ - "Required RPC methods not available." + assert "system.client_version" in self._get_rpc_methods(), "Required RPC method not available." + assert "system.library_version" in self._get_rpc_methods(), "Required RPC method not available." # minimum rTorrent version check - assert self._meets_version_requirement() is True,\ "Error: Minimum rTorrent version required is {0}".format( MIN_RTORRENT_VERSION_STR) diff --git a/libs/rtorrent/lib/torrentparser.py b/libs/rtorrent/lib/torrentparser.py index 19dd12a..30170d3 100755 --- a/libs/rtorrent/lib/torrentparser.py +++ b/libs/rtorrent/lib/torrentparser.py @@ -90,9 +90,10 @@ class TorrentParser(): def _calc_info_hash(self): self.info_hash = None if "info" in self._torrent_decoded.keys(): - info_dict = self._torrent_decoded["info"] - self.info_hash = hashlib.sha1(bencode.encode( - info_dict)).hexdigest().upper() + info_encoded = bencode.encode(self._torrent_decoded["info"]) + + if info_encoded: + self.info_hash = hashlib.sha1(info_encoded).hexdigest().upper() return(self.info_hash)