forked from premiere/premiere-libtorrent
merge RC_1_1 into master
This commit is contained in:
commit
fc56ec194a
|
@ -156,7 +156,7 @@ def print_download_queue(console, download_queue):
|
|||
def add_torrent(ses, filename, options):
|
||||
atp = lt.add_torrent_params()
|
||||
if filename.startswith('magnet:'):
|
||||
atp = lt.parse_magnet_uti(filename)
|
||||
atp = lt.parse_magnet_uri(filename)
|
||||
else:
|
||||
atp.ti = lt.torrent_info(filename)
|
||||
try:
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
dict parse_magnet_uri_wrap(std::string const& uri)
|
||||
dict parse_magnet_uri_dict(std::string const& uri)
|
||||
{
|
||||
error_code ec;
|
||||
add_torrent_params p = parse_magnet_uri(uri, ec);
|
||||
|
@ -69,6 +69,14 @@ namespace {
|
|||
return ret;
|
||||
}
|
||||
|
||||
add_torrent_params parse_magnet_uri_wrap(std::string const& uri)
|
||||
{
|
||||
error_code ec;
|
||||
add_torrent_params p = parse_magnet_uri(uri, ec);
|
||||
if (ec) throw system_error(ec);
|
||||
return p;
|
||||
}
|
||||
|
||||
std::string (*make_magnet_uri0)(torrent_handle const&) = make_magnet_uri;
|
||||
std::string (*make_magnet_uri1)(torrent_info const&) = make_magnet_uri;
|
||||
}
|
||||
|
@ -81,4 +89,5 @@ void bind_magnet_uri()
|
|||
def("make_magnet_uri", make_magnet_uri0);
|
||||
def("make_magnet_uri", make_magnet_uri1);
|
||||
def("parse_magnet_uri", parse_magnet_uri_wrap);
|
||||
def("parse_magnet_uri_dict", parse_magnet_uri_dict);
|
||||
}
|
||||
|
|
|
@ -423,9 +423,19 @@ class test_sha1hash(unittest.TestCase):
|
|||
class test_magnet_link(unittest.TestCase):
|
||||
|
||||
def test_parse_magnet_uri(self):
|
||||
ses = lt.session(settings)
|
||||
ses = lt.session({})
|
||||
magnet = 'magnet:?xt=urn:btih:C6EIF4CCYDBTIJVG3APAGM7M4NDONCTI'
|
||||
p = lt.parse_magnet_uri(magnet)
|
||||
self.assertEqual(str(p.info_hash), '178882f042c0c33426a6d81e0333ece346e68a68')
|
||||
p.save_path = '.'
|
||||
h = ses.add_torrent(p)
|
||||
self.assertEqual(str(h.info_hash()), '178882f042c0c33426a6d81e0333ece346e68a68')
|
||||
|
||||
def test_parse_magnet_uri_dict(self):
|
||||
ses = lt.session({})
|
||||
magnet = 'magnet:?xt=urn:btih:C6EIF4CCYDBTIJVG3APAGM7M4NDONCTI'
|
||||
p = lt.parse_magnet_uri_dict(magnet)
|
||||
self.assertEqual(binascii.hexlify(p['info_hash']), b'178882f042c0c33426a6d81e0333ece346e68a68')
|
||||
p['save_path'] = '.'
|
||||
h = ses.add_torrent(p)
|
||||
self.assertEqual(str(h.info_hash()), '178882f042c0c33426a6d81e0333ece346e68a68')
|
||||
|
|
|
@ -10,14 +10,14 @@ if $(BOOST_ROOT)
|
|||
}
|
||||
|
||||
project client_test
|
||||
: requirements
|
||||
: requirements
|
||||
<threading>multi <library>/torrent//torrent
|
||||
<toolset>darwin:<cflags>-Wno-unused-command-line-argument
|
||||
# disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier'
|
||||
<toolset>msvc:<cflags>/wd4275
|
||||
: default-build
|
||||
<link>static
|
||||
;
|
||||
;
|
||||
|
||||
exe client_test : client_test.cpp print.cpp torrent_view.cpp session_view.cpp ;
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <deque>
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <algorithm> // for min()/max()
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue