fix python binding for parse_magnet_uri (#1838)

fix python binding for parse_magnet_uri
This commit is contained in:
Arvid Norberg 2017-03-23 08:31:10 -04:00 committed by GitHub
parent 4d397f5ebf
commit 2e367ea53b
3 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,4 @@
* fix python binding for parse_magnet_uri
* fix minor robustness issue in DHT bootstrap logic * fix minor robustness issue in DHT bootstrap logic
* fix issue where torrent_status::num_seeds could be negative * fix issue where torrent_status::num_seeds could be negative
* document deprecation of dynamic loading/unloading of torrents * document deprecation of dynamic loading/unloading of torrents

View File

@ -58,7 +58,7 @@ namespace {
, end(p.dht_nodes.end()); i != end; ++i) , end(p.dht_nodes.end()); i != end; ++i)
tracker_list.append(boost::python::make_tuple(i->first, i->second)); tracker_list.append(boost::python::make_tuple(i->first, i->second));
ret["dht_nodes"] = nodes_list; ret["dht_nodes"] = nodes_list;
ret["info_hash"] = p.info_hash; ret["info_hash"] = p.info_hash.to_string();
ret["name"] = p.name; ret["name"] = p.name;
ret["save_path"] = p.save_path; ret["save_path"] = p.save_path;
ret["storage_mode"] = p.storage_mode; ret["storage_mode"] = p.storage_mode;

View File

@ -256,6 +256,15 @@ class test_sha1hash(unittest.TestCase):
s = lt.sha1_hash(binascii.unhexlify(h)) s = lt.sha1_hash(binascii.unhexlify(h))
self.assertEqual(h, str(s)) self.assertEqual(h, str(s))
class test_magnet_link(unittest.TestCase):
def test_parse_magnet_uri(self):
ses = lt.session({})
magnet = 'magnet:?xt=urn:btih:C6EIF4CCYDBTIJVG3APAGM7M4NDONCTI'
p = lt.parse_magnet_uri(magnet)
p['save_path'] = '.'
h = ses.add_torrent(p)
self.assertEqual(str(h.info_hash()), '178882f042c0c33426a6d81e0333ece346e68a68')
class test_session(unittest.TestCase): class test_session(unittest.TestCase):