2007-01-10 17:11:43 +01:00
|
|
|
// Copyright Daniel Wallin 2006. Use, modification and distribution is
|
|
|
|
// subject to the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
2016-04-08 04:45:23 +02:00
|
|
|
#include "boost_python.hpp"
|
2008-08-18 14:29:01 +02:00
|
|
|
#include <boost/python/tuple.hpp>
|
2016-04-02 08:29:24 +02:00
|
|
|
#include <boost/python/stl_iterator.hpp>
|
2009-03-02 06:23:25 +01:00
|
|
|
#include <libtorrent/torrent_handle.hpp>
|
2015-09-18 06:23:45 +02:00
|
|
|
#include <libtorrent/torrent_info.hpp>
|
|
|
|
#include <libtorrent/torrent_status.hpp>
|
|
|
|
#include <libtorrent/entry.hpp>
|
2009-12-05 08:24:22 +01:00
|
|
|
#include <libtorrent/peer_info.hpp>
|
2015-09-18 06:23:45 +02:00
|
|
|
#include "libtorrent/announce_entry.hpp"
|
2015-09-30 01:17:28 +02:00
|
|
|
#include <libtorrent/storage.hpp>
|
2017-04-09 00:24:50 +02:00
|
|
|
#include <libtorrent/disk_interface.hpp>
|
2008-03-27 19:14:52 +01:00
|
|
|
#include <boost/lexical_cast.hpp>
|
2007-01-10 17:11:43 +01:00
|
|
|
#include "gil.hpp"
|
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
using namespace libtorrent;
|
|
|
|
|
2016-06-19 01:24:27 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
// warning c4996: x: was declared deprecated
|
|
|
|
#pragma warning( disable : 4996 )
|
|
|
|
#endif
|
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2008-03-28 22:37:35 +01:00
|
|
|
list url_seeds(torrent_handle& handle)
|
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::set<std::string> urls;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
urls = handle.url_seeds();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::set<std::string>::iterator i(urls.begin())
|
|
|
|
, end(urls.end()); i != end; ++i)
|
|
|
|
ret.append(*i);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
list http_seeds(torrent_handle& handle)
|
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::set<std::string> urls;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
urls = handle.http_seeds();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::set<std::string>::iterator i(urls.begin())
|
|
|
|
, end(urls.end()); i != end; ++i)
|
|
|
|
ret.append(*i);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-28 22:37:35 +01:00
|
|
|
list piece_availability(torrent_handle& handle)
|
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::vector<int> avail;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
handle.piece_availability(avail);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::vector<int>::iterator i(avail.begin())
|
|
|
|
, end(avail.end()); i != end; ++i)
|
|
|
|
ret.append(*i);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
list piece_priorities(torrent_handle& handle)
|
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::vector<int> prio;
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
prio = handle.piece_priorities();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::vector<int>::iterator i(prio.begin())
|
|
|
|
, end(prio.end()); i != end; ++i)
|
|
|
|
ret.append(*i);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
} // namespace unnamed
|
|
|
|
|
2014-01-17 06:35:58 +01:00
|
|
|
list file_progress(torrent_handle& handle, int flags)
|
2007-01-10 17:11:43 +01:00
|
|
|
{
|
2016-06-18 20:01:38 +02:00
|
|
|
std::vector<std::int64_t> p;
|
2007-01-10 17:11:43 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
2016-08-17 23:26:35 +02:00
|
|
|
std::shared_ptr<const torrent_info> ti = handle.torrent_file();
|
2015-01-28 06:03:34 +01:00
|
|
|
if (ti)
|
|
|
|
{
|
|
|
|
p.reserve(ti->num_files());
|
|
|
|
handle.file_progress(p, flags);
|
|
|
|
}
|
2007-01-10 17:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
list result;
|
|
|
|
|
2016-06-18 20:01:38 +02:00
|
|
|
for (std::vector<std::int64_t>::iterator i(p.begin()), e(p.end()); i != e; ++i)
|
2007-01-10 17:11:43 +01:00
|
|
|
result.append(*i);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
list get_peer_info(torrent_handle const& handle)
|
|
|
|
{
|
|
|
|
std::vector<peer_info> pi;
|
|
|
|
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
handle.get_peer_info(pi);
|
|
|
|
}
|
|
|
|
|
|
|
|
list result;
|
|
|
|
|
|
|
|
for (std::vector<peer_info>::iterator i = pi.begin(); i != pi.end(); ++i)
|
|
|
|
result.append(*i);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-04-04 06:22:01 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
T extract_fn(object o)
|
|
|
|
{
|
|
|
|
return boost::python::extract<T>(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-28 22:37:35 +01:00
|
|
|
void prioritize_pieces(torrent_handle& info, object o)
|
|
|
|
{
|
2016-04-04 06:22:01 +02:00
|
|
|
stl_input_iterator<object> begin(o), end;
|
|
|
|
if (begin == end) return;
|
|
|
|
|
|
|
|
// determine which overload should be selected. the one taking a list of
|
|
|
|
// priorities or the one taking a list of piece -> priority mappings
|
2016-12-22 16:42:33 +01:00
|
|
|
bool const is_piece_list = extract<std::pair<piece_index_t, int>>(*begin).check();
|
2016-04-04 06:22:01 +02:00
|
|
|
|
|
|
|
if (is_piece_list)
|
2008-03-28 22:37:35 +01:00
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
std::vector<std::pair<piece_index_t, int>> piece_list;
|
2016-04-04 06:22:01 +02:00
|
|
|
std::transform(begin, end, std::back_inserter(piece_list)
|
2016-12-22 16:42:33 +01:00
|
|
|
, &extract_fn<std::pair<piece_index_t, int>>);
|
2016-04-04 06:22:01 +02:00
|
|
|
info.prioritize_pieces(piece_list);
|
2008-03-28 22:37:35 +01:00
|
|
|
}
|
2016-04-04 06:22:01 +02:00
|
|
|
else
|
2008-03-28 22:37:35 +01:00
|
|
|
{
|
2016-04-04 06:22:01 +02:00
|
|
|
std::vector<int> priority_vector;
|
|
|
|
std::transform(begin, end, std::back_inserter(priority_vector)
|
|
|
|
, &extract_fn<int>);
|
|
|
|
info.prioritize_pieces(priority_vector);
|
2008-03-28 22:37:35 +01:00
|
|
|
}
|
|
|
|
}
|
2007-07-23 05:07:15 +02:00
|
|
|
|
|
|
|
void prioritize_files(torrent_handle& info, object o)
|
|
|
|
{
|
2016-04-02 08:29:24 +02:00
|
|
|
stl_input_iterator<int const> begin(o), end;
|
2016-04-04 06:22:01 +02:00
|
|
|
info.prioritize_files(std::vector<int> (begin, end));
|
2007-07-23 05:07:15 +02:00
|
|
|
}
|
|
|
|
|
2008-10-08 14:41:55 +02:00
|
|
|
list file_priorities(torrent_handle& handle)
|
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::vector<int> priorities = handle.file_priorities();
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2008-10-08 14:41:55 +02:00
|
|
|
for (std::vector<int>::iterator i = priorities.begin(); i != priorities.end(); ++i)
|
|
|
|
ret.append(*i);
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2008-10-08 14:41:55 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2007-07-23 05:07:15 +02:00
|
|
|
|
2016-12-22 16:42:33 +01:00
|
|
|
int file_prioritity0(torrent_handle& h, file_index_t index)
|
2012-05-20 01:34:31 +02:00
|
|
|
{
|
2012-08-18 21:33:24 +02:00
|
|
|
return h.file_priority(index);
|
2012-05-20 01:34:31 +02:00
|
|
|
}
|
|
|
|
|
2016-12-22 16:42:33 +01:00
|
|
|
void file_prioritity1(torrent_handle& h, file_index_t index, int prio)
|
2012-05-20 01:34:31 +02:00
|
|
|
{
|
2012-08-18 21:33:24 +02:00
|
|
|
return h.file_priority(index, prio);
|
2012-05-20 01:34:31 +02:00
|
|
|
}
|
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
void dict_to_announce_entry(dict d, announce_entry& ae)
|
|
|
|
{
|
2013-07-16 17:55:14 +02:00
|
|
|
ae.url = extract<std::string>(d["url"]);
|
2013-05-03 10:24:26 +02:00
|
|
|
if (d.has_key("tier"))
|
|
|
|
ae.tier = extract<int>(d["tier"]);
|
|
|
|
if (d.has_key("fail_limit"))
|
|
|
|
ae.fail_limit = extract<int>(d["fail_limit"]);
|
|
|
|
}
|
|
|
|
|
2009-06-04 04:14:34 +02:00
|
|
|
void replace_trackers(torrent_handle& h, object trackers)
|
2007-01-10 17:11:43 +01:00
|
|
|
{
|
|
|
|
object iter(trackers.attr("__iter__")());
|
|
|
|
|
|
|
|
std::vector<announce_entry> result;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
handle<> entry(allow_null(PyIter_Next(iter.ptr())));
|
|
|
|
|
|
|
|
if (entry == handle<>())
|
|
|
|
break;
|
|
|
|
|
2012-08-18 21:33:24 +02:00
|
|
|
if (extract<announce_entry>(object(entry)).check())
|
|
|
|
{
|
|
|
|
result.push_back(extract<announce_entry>(object(entry)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dict d;
|
|
|
|
d = extract<dict>(object(entry));
|
2013-05-03 10:24:26 +02:00
|
|
|
announce_entry ae;
|
2013-07-16 17:55:14 +02:00
|
|
|
dict_to_announce_entry(d, ae);
|
|
|
|
result.push_back(ae);
|
2012-08-18 21:33:24 +02:00
|
|
|
}
|
2007-01-10 17:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
allow_threading_guard guard;
|
2009-06-04 04:14:34 +02:00
|
|
|
h.replace_trackers(result);
|
|
|
|
}
|
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
void add_tracker(torrent_handle& h, dict d)
|
|
|
|
{
|
2013-07-16 17:55:14 +02:00
|
|
|
announce_entry ae;
|
|
|
|
dict_to_announce_entry(d, ae);
|
|
|
|
h.add_tracker(ae);
|
2013-05-03 10:24:26 +02:00
|
|
|
}
|
|
|
|
|
2017-03-29 02:22:27 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
#if defined BOOST_ASIO_HAS_STD_CHRONO
|
|
|
|
using std::chrono::system_clock;
|
|
|
|
#else
|
|
|
|
using boost::chrono::system_clock;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
time_t to_ptime(time_point tpt)
|
|
|
|
{
|
|
|
|
return system_clock::to_time_t(system_clock::now()
|
|
|
|
+ duration_cast<system_clock::duration>(tpt - clock_type::now()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
list trackers(torrent_handle& h)
|
2009-06-04 04:14:34 +02:00
|
|
|
{
|
|
|
|
list ret;
|
|
|
|
std::vector<announce_entry> const trackers = h.trackers();
|
|
|
|
for (std::vector<announce_entry>::const_iterator i = trackers.begin(), end(trackers.end()); i != end; ++i)
|
|
|
|
{
|
|
|
|
dict d;
|
|
|
|
d["url"] = i->url;
|
2017-01-30 17:13:57 +01:00
|
|
|
d["trackerid"] = i->trackerid;
|
|
|
|
d["message"] = i->message;
|
2017-02-24 22:13:49 +01:00
|
|
|
dict last_error;
|
|
|
|
last_error["value"] = i->last_error.value();
|
|
|
|
last_error["category"] = i->last_error.category().name();
|
|
|
|
d["last_error"] = last_error;
|
2017-03-29 02:22:27 +02:00
|
|
|
if (i->next_announce > min_time()) {
|
|
|
|
d["next_announce"] = to_ptime(i->next_announce);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
d["next_announce"] = object();
|
|
|
|
}
|
|
|
|
if (i->min_announce > min_time()) {
|
|
|
|
d["min_announce"] = to_ptime(i->min_announce);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
d["min_announce"] = object();
|
|
|
|
}
|
2017-01-30 17:13:57 +01:00
|
|
|
d["scrape_incomplete"] = i->scrape_incomplete;
|
|
|
|
d["scrape_complete"] = i->scrape_complete;
|
|
|
|
d["scrape_downloaded"] = i->scrape_downloaded;
|
2009-06-04 04:14:34 +02:00
|
|
|
d["tier"] = i->tier;
|
|
|
|
d["fail_limit"] = i->fail_limit;
|
|
|
|
d["fails"] = i->fails;
|
|
|
|
d["source"] = i->source;
|
|
|
|
d["verified"] = i->verified;
|
|
|
|
d["updating"] = i->updating;
|
|
|
|
d["start_sent"] = i->start_sent;
|
|
|
|
d["complete_sent"] = i->complete_sent;
|
2016-09-22 01:54:49 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2012-08-18 21:33:24 +02:00
|
|
|
d["send_stats"] = i->send_stats;
|
2016-09-22 01:54:49 +02:00
|
|
|
#endif
|
2009-06-04 04:14:34 +02:00
|
|
|
ret.append(d);
|
|
|
|
}
|
|
|
|
return ret;
|
2007-01-10 17:11:43 +01:00
|
|
|
}
|
|
|
|
|
2007-04-19 03:26:23 +02:00
|
|
|
list get_download_queue(torrent_handle& handle)
|
|
|
|
{
|
2008-03-28 22:37:35 +01:00
|
|
|
list ret;
|
|
|
|
|
|
|
|
std::vector<partial_piece_info> downloading;
|
|
|
|
|
|
|
|
{
|
|
|
|
allow_threading_guard guard;
|
|
|
|
handle.get_download_queue(downloading);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::vector<partial_piece_info>::iterator i = downloading.begin()
|
|
|
|
, end(downloading.end()); i != end; ++i)
|
|
|
|
{
|
|
|
|
dict partial_piece;
|
|
|
|
partial_piece["piece_index"] = i->piece_index;
|
|
|
|
partial_piece["blocks_in_piece"] = i->blocks_in_piece;
|
|
|
|
list block_list;
|
|
|
|
for (int k = 0; k < i->blocks_in_piece; ++k)
|
|
|
|
{
|
|
|
|
dict block_info;
|
|
|
|
block_info["state"] = i->blocks[k].state;
|
|
|
|
block_info["num_peers"] = i->blocks[k].num_peers;
|
|
|
|
block_info["bytes_progress"] = i->blocks[k].bytes_progress;
|
|
|
|
block_info["block_size"] = i->blocks[k].block_size;
|
2014-11-30 01:28:03 +01:00
|
|
|
block_info["peer"] = boost::python::make_tuple(
|
2015-01-26 03:07:03 +01:00
|
|
|
i->blocks[k].peer().address().to_string()
|
2016-06-19 01:24:27 +02:00
|
|
|
, i->blocks[k].peer().port());
|
2008-03-28 22:37:35 +01:00
|
|
|
block_list.append(block_info);
|
|
|
|
}
|
|
|
|
partial_piece["blocks"] = block_list;
|
|
|
|
|
|
|
|
ret.append(partial_piece);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2007-04-19 03:26:23 +02:00
|
|
|
}
|
|
|
|
|
2013-05-03 10:24:26 +02:00
|
|
|
void set_metadata(torrent_handle& handle, std::string const& buf)
|
|
|
|
{
|
2016-08-22 17:02:51 +02:00
|
|
|
handle.set_metadata(buf);
|
2013-05-03 10:24:26 +02:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:41:39 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2013-09-07 23:27:07 +02:00
|
|
|
#if BOOST_VERSION > 104200
|
|
|
|
|
2016-08-17 23:26:35 +02:00
|
|
|
std::shared_ptr<const torrent_info> get_torrent_info(torrent_handle const& h)
|
2013-08-28 04:38:31 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
allow_threading_guard guard;
|
|
|
|
return h.torrent_file();
|
2013-09-07 23:27:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-08-17 23:26:35 +02:00
|
|
|
std::shared_ptr<torrent_info> get_torrent_info(torrent_handle const& h)
|
2013-09-07 23:27:07 +02:00
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
// I can't figure out how to expose shared_ptr<const torrent_info>
|
2013-09-07 23:27:07 +02:00
|
|
|
// as well as supporting mutable instances. So, this hack is better
|
|
|
|
// than compilation errors. It seems to work on newer versions of boost though
|
2014-07-06 21:18:00 +02:00
|
|
|
allow_threading_guard guard;
|
2016-08-17 23:26:35 +02:00
|
|
|
return std::const_pointer_cast<torrent_info>(h.torrent_file());
|
2013-08-28 04:38:31 +02:00
|
|
|
}
|
|
|
|
|
2013-09-07 23:27:07 +02:00
|
|
|
#endif
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
#endif // TORRENT_NO_DEPRECAE
|
2008-03-27 19:14:52 +01:00
|
|
|
|
2016-12-22 16:42:33 +01:00
|
|
|
void add_piece(torrent_handle& th, piece_index_t piece, char const *data, int flags)
|
2008-12-13 05:09:53 +01:00
|
|
|
{
|
|
|
|
th.add_piece(piece, data, flags);
|
|
|
|
}
|
|
|
|
|
2017-01-24 14:50:36 +01:00
|
|
|
using by_value = return_value_policy<return_by_value>;
|
2007-01-10 17:11:43 +01:00
|
|
|
void bind_torrent_handle()
|
|
|
|
{
|
2014-01-02 03:16:31 +01:00
|
|
|
// arguments are: number of seconds and tracker index
|
|
|
|
void (torrent_handle::*force_reannounce0)(int, int) const = &torrent_handle::force_reannounce;
|
2007-01-10 17:11:43 +01:00
|
|
|
|
2012-06-14 17:41:39 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2011-11-16 07:12:48 +01:00
|
|
|
bool (torrent_handle::*super_seeding0)() const = &torrent_handle::super_seeding;
|
2012-06-14 17:41:39 +02:00
|
|
|
#endif
|
2011-11-16 07:12:48 +01:00
|
|
|
void (torrent_handle::*super_seeding1)(bool) const = &torrent_handle::super_seeding;
|
|
|
|
|
2016-12-22 16:42:33 +01:00
|
|
|
int (torrent_handle::*piece_priority0)(piece_index_t) const = &torrent_handle::piece_priority;
|
|
|
|
void (torrent_handle::*piece_priority1)(piece_index_t, int) const = &torrent_handle::piece_priority;
|
2008-03-28 22:37:35 +01:00
|
|
|
|
2013-05-09 04:50:16 +02:00
|
|
|
void (torrent_handle::*move_storage0)(std::string const&, int flags) const = &torrent_handle::move_storage;
|
2016-12-22 16:42:33 +01:00
|
|
|
void (torrent_handle::*rename_file0)(file_index_t, std::string const&) const = &torrent_handle::rename_file;
|
2008-12-13 04:44:18 +01:00
|
|
|
|
2013-08-27 18:04:19 +02:00
|
|
|
#if TORRENT_USE_WSTRING && !defined TORRENT_NO_DEPRECATE
|
2013-05-09 04:50:16 +02:00
|
|
|
void (torrent_handle::*move_storage1)(std::wstring const&, int flags) const = &torrent_handle::move_storage;
|
2016-12-22 16:42:33 +01:00
|
|
|
void (torrent_handle::*rename_file1)(file_index_t, std::wstring const&) const = &torrent_handle::rename_file;
|
2009-10-26 02:29:39 +01:00
|
|
|
#endif
|
2009-06-04 04:14:34 +02:00
|
|
|
|
2017-04-09 00:24:50 +02:00
|
|
|
std::vector<open_file_state> (torrent_handle::*file_status0)() const = &torrent_handle::file_status;
|
2016-12-30 00:06:56 +01:00
|
|
|
|
2007-01-10 17:11:43 +01:00
|
|
|
#define _ allow_threads
|
|
|
|
|
|
|
|
class_<torrent_handle>("torrent_handle")
|
2011-07-04 23:02:15 +02:00
|
|
|
.def(self == self)
|
|
|
|
.def(self != self)
|
|
|
|
.def(self < self)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("get_peer_info", get_peer_info)
|
2011-03-05 03:31:12 +01:00
|
|
|
.def("status", _(&torrent_handle::status), arg("flags") = 0xffffffff)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("get_download_queue", get_download_queue)
|
2014-01-17 06:35:58 +01:00
|
|
|
.def("file_progress", file_progress, arg("flags") = 0)
|
2009-06-04 04:14:34 +02:00
|
|
|
.def("trackers", trackers)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("replace_trackers", replace_trackers)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("add_tracker", add_tracker)
|
2007-01-10 17:11:43 +01:00
|
|
|
.def("add_url_seed", _(&torrent_handle::add_url_seed))
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("remove_url_seed", _(&torrent_handle::remove_url_seed))
|
|
|
|
.def("url_seeds", url_seeds)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("add_http_seed", _(&torrent_handle::add_http_seed))
|
|
|
|
.def("remove_http_seed", _(&torrent_handle::remove_http_seed))
|
|
|
|
.def("http_seeds", http_seeds)
|
2013-08-28 04:38:31 +02:00
|
|
|
.def("torrent_file", _(&torrent_handle::torrent_file))
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("set_metadata", set_metadata)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("is_valid", _(&torrent_handle::is_valid))
|
2010-10-30 10:36:18 +02:00
|
|
|
.def("pause", _(&torrent_handle::pause), arg("flags") = 0)
|
2007-01-10 17:11:43 +01:00
|
|
|
.def("resume", _(&torrent_handle::resume))
|
2015-10-04 00:15:29 +02:00
|
|
|
.def("stop_when_ready", _(&torrent_handle::stop_when_ready))
|
2008-07-12 19:00:52 +02:00
|
|
|
.def("clear_error", _(&torrent_handle::clear_error))
|
2011-11-16 07:12:48 +01:00
|
|
|
.def("super_seeding", super_seeding1)
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2008-06-02 23:18:50 +02:00
|
|
|
.def("auto_managed", _(&torrent_handle::auto_managed))
|
2008-06-04 07:16:31 +02:00
|
|
|
.def("queue_position", _(&torrent_handle::queue_position))
|
2008-06-02 23:18:50 +02:00
|
|
|
.def("queue_position_up", _(&torrent_handle::queue_position_up))
|
|
|
|
.def("queue_position_down", _(&torrent_handle::queue_position_down))
|
|
|
|
.def("queue_position_top", _(&torrent_handle::queue_position_top))
|
|
|
|
.def("queue_position_bottom", _(&torrent_handle::queue_position_bottom))
|
2008-10-28 07:29:30 +01:00
|
|
|
|
2015-12-15 00:31:49 +01:00
|
|
|
// deprecated
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2016-08-26 18:37:23 +02:00
|
|
|
.def("set_priority", _(&torrent_handle::set_priority))
|
2014-07-06 21:18:00 +02:00
|
|
|
.def("get_torrent_info", &get_torrent_info)
|
2012-06-14 17:41:39 +02:00
|
|
|
.def("super_seeding", super_seeding0)
|
2008-10-28 07:29:30 +01:00
|
|
|
.def("write_resume_data", _(&torrent_handle::write_resume_data))
|
2011-01-23 19:41:15 +01:00
|
|
|
.def("is_seed", _(&torrent_handle::is_seed))
|
|
|
|
.def("is_finished", _(&torrent_handle::is_finished))
|
|
|
|
.def("is_paused", _(&torrent_handle::is_paused))
|
|
|
|
.def("is_auto_managed", _(&torrent_handle::is_auto_managed))
|
|
|
|
.def("has_metadata", _(&torrent_handle::has_metadata))
|
2013-08-28 04:38:31 +02:00
|
|
|
.def("use_interface", &torrent_handle::use_interface)
|
|
|
|
.def("name", _(&torrent_handle::name))
|
2008-10-28 07:29:30 +01:00
|
|
|
#endif
|
2008-12-13 05:09:53 +01:00
|
|
|
.def("add_piece", add_piece)
|
2008-12-15 08:49:05 +01:00
|
|
|
.def("read_piece", _(&torrent_handle::read_piece))
|
2011-11-27 01:01:13 +01:00
|
|
|
.def("have_piece", _(&torrent_handle::have_piece))
|
2009-12-05 08:24:22 +01:00
|
|
|
.def("set_piece_deadline", _(&torrent_handle::set_piece_deadline)
|
2009-09-25 17:03:24 +02:00
|
|
|
, (arg("index"), arg("deadline"), arg("flags") = 0))
|
2011-08-05 19:11:05 +02:00
|
|
|
.def("reset_piece_deadline", _(&torrent_handle::reset_piece_deadline), (arg("index")))
|
2016-12-23 22:57:10 +01:00
|
|
|
.def("clear_piece_deadlines", _(&torrent_handle::clear_piece_deadlines), (arg("index")))
|
2009-09-25 17:03:24 +02:00
|
|
|
.def("piece_availability", &piece_availability)
|
2007-07-23 05:07:15 +02:00
|
|
|
.def("piece_priority", _(piece_priority0))
|
|
|
|
.def("piece_priority", _(piece_priority1))
|
2009-09-25 17:03:24 +02:00
|
|
|
.def("prioritize_pieces", &prioritize_pieces)
|
|
|
|
.def("piece_priorities", &piece_priorities)
|
|
|
|
.def("prioritize_files", &prioritize_files)
|
|
|
|
.def("file_priorities", &file_priorities)
|
2012-05-20 01:34:31 +02:00
|
|
|
.def("file_priority", &file_prioritity0)
|
|
|
|
.def("file_priority", &file_prioritity1)
|
2016-12-30 00:06:56 +01:00
|
|
|
.def("file_status", _(file_status0))
|
2010-10-30 18:59:17 +02:00
|
|
|
.def("save_resume_data", _(&torrent_handle::save_resume_data), arg("flags") = 0)
|
2010-04-12 02:36:31 +02:00
|
|
|
.def("need_save_resume_data", _(&torrent_handle::need_save_resume_data))
|
2014-01-02 03:16:31 +01:00
|
|
|
.def("force_reannounce", _(force_reannounce0)
|
2015-12-15 00:31:49 +01:00
|
|
|
, (arg("seconds") = 0, arg("tracker_idx") = -1))
|
2011-04-28 11:24:42 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2009-10-25 03:37:45 +01:00
|
|
|
.def("force_dht_announce", _(&torrent_handle::force_dht_announce))
|
2011-04-28 11:24:42 +02:00
|
|
|
#endif
|
2016-09-28 05:22:06 +02:00
|
|
|
.def("scrape_tracker", _(&torrent_handle::scrape_tracker), arg("index") = -1)
|
2010-09-05 18:49:03 +02:00
|
|
|
.def("set_upload_mode", _(&torrent_handle::set_upload_mode))
|
|
|
|
.def("set_share_mode", _(&torrent_handle::set_share_mode))
|
2013-03-28 00:34:26 +01:00
|
|
|
.def("flush_cache", &torrent_handle::flush_cache)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("apply_ip_filter", &torrent_handle::apply_ip_filter)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("set_upload_limit", _(&torrent_handle::set_upload_limit))
|
|
|
|
.def("upload_limit", _(&torrent_handle::upload_limit))
|
|
|
|
.def("set_download_limit", _(&torrent_handle::set_download_limit))
|
|
|
|
.def("download_limit", _(&torrent_handle::download_limit))
|
|
|
|
.def("set_sequential_download", _(&torrent_handle::set_sequential_download))
|
2012-06-14 17:41:39 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2016-04-13 02:10:09 +02:00
|
|
|
.def("set_peer_upload_limit", &torrent_handle::set_peer_upload_limit)
|
|
|
|
.def("set_peer_download_limit", &torrent_handle::set_peer_download_limit)
|
2008-03-28 22:37:35 +01:00
|
|
|
.def("set_ratio", _(&torrent_handle::set_ratio))
|
2013-08-28 04:38:31 +02:00
|
|
|
.def("save_path", _(&torrent_handle::save_path))
|
2012-06-14 17:41:39 +02:00
|
|
|
#endif
|
2016-04-13 02:10:09 +02:00
|
|
|
.def("connect_peer", &torrent_handle::connect_peer, (arg("endpoint"), arg("source")=0, arg("flags")=0xd))
|
|
|
|
.def("set_max_uploads", &torrent_handle::set_max_uploads)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("max_uploads", _(&torrent_handle::max_uploads))
|
2016-04-13 02:10:09 +02:00
|
|
|
.def("set_max_connections", &torrent_handle::set_max_connections)
|
2013-05-03 10:24:26 +02:00
|
|
|
.def("max_connections", _(&torrent_handle::max_connections))
|
2015-12-13 22:25:05 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2016-04-13 02:10:09 +02:00
|
|
|
.def("set_tracker_login", &torrent_handle::set_tracker_login)
|
2015-12-13 22:25:05 +01:00
|
|
|
#endif
|
2013-05-09 04:50:16 +02:00
|
|
|
.def("move_storage", _(move_storage0), (arg("path"), arg("flags") = 0))
|
2008-04-16 00:32:53 +02:00
|
|
|
.def("info_hash", _(&torrent_handle::info_hash))
|
2008-06-07 23:02:14 +02:00
|
|
|
.def("force_recheck", _(&torrent_handle::force_recheck))
|
2008-12-13 04:44:18 +01:00
|
|
|
.def("rename_file", _(rename_file0))
|
2012-06-27 01:53:59 +02:00
|
|
|
.def("set_ssl_certificate", &torrent_handle::set_ssl_certificate, (arg("cert"), arg("private_key"), arg("dh_params"), arg("passphrase")=""))
|
2013-08-27 18:04:19 +02:00
|
|
|
#if TORRENT_USE_WSTRING && !defined TORRENT_NO_DEPRECATE
|
2013-05-09 04:50:16 +02:00
|
|
|
.def("move_storage", _(move_storage1), (arg("path"), arg("flags") = 0))
|
2008-12-13 04:44:18 +01:00
|
|
|
.def("rename_file", _(rename_file1))
|
2009-10-26 02:29:39 +01:00
|
|
|
#endif
|
2007-01-10 17:11:43 +01:00
|
|
|
;
|
2009-09-25 17:03:24 +02:00
|
|
|
|
2017-04-09 00:24:50 +02:00
|
|
|
class_<open_file_state>("open_file_state")
|
|
|
|
.add_property("file_index", make_getter((&open_file_state::file_index), by_value()))
|
|
|
|
.def_readonly("last_use", &open_file_state::last_use)
|
|
|
|
.def_readonly("open_mode", &open_file_state::open_mode)
|
2016-12-23 22:57:10 +01:00
|
|
|
;
|
|
|
|
|
2017-04-09 00:24:50 +02:00
|
|
|
enum_<file_open_mode>("file_open_mode")
|
|
|
|
.value("read_only", file_open_mode::read_only)
|
|
|
|
.value("write_only", file_open_mode::write_only)
|
|
|
|
.value("read_write", file_open_mode::read_write)
|
|
|
|
.value("rw_mask", file_open_mode::rw_mask)
|
|
|
|
.value("sparse", file_open_mode::sparse)
|
|
|
|
.value("no_atime", file_open_mode::no_atime)
|
|
|
|
.value("random_access", file_open_mode::random_access)
|
|
|
|
.value("locked", file_open_mode::locked)
|
|
|
|
;
|
|
|
|
|
2014-01-17 06:35:58 +01:00
|
|
|
enum_<torrent_handle::file_progress_flags_t>("file_progress_flags")
|
|
|
|
.value("piece_granularity", torrent_handle::piece_granularity)
|
|
|
|
;
|
|
|
|
|
2016-12-23 22:57:10 +01:00
|
|
|
enum_<torrent_handle::flags_t>("add_piece_flags_t")
|
|
|
|
.value("overwrite_existing", torrent_handle::overwrite_existing)
|
|
|
|
;
|
2010-10-30 18:59:17 +02:00
|
|
|
enum_<torrent_handle::pause_flags_t>("pause_flags_t")
|
2010-10-30 10:36:18 +02:00
|
|
|
.value("graceful_pause", torrent_handle::graceful_pause)
|
|
|
|
;
|
|
|
|
|
2010-10-29 04:21:43 +02:00
|
|
|
enum_<torrent_handle::save_resume_flags_t>("save_resume_flags_t")
|
|
|
|
.value("flush_disk_cache", torrent_handle::flush_disk_cache)
|
2016-12-23 22:57:10 +01:00
|
|
|
.value("save_info_dict", torrent_handle::save_info_dict)
|
|
|
|
.value("only_if_modified", torrent_handle::only_if_modified)
|
2010-10-29 04:21:43 +02:00
|
|
|
;
|
|
|
|
|
2009-09-25 17:03:24 +02:00
|
|
|
enum_<torrent_handle::deadline_flags>("deadline_flags")
|
|
|
|
.value("alert_when_available", torrent_handle::alert_when_available)
|
|
|
|
;
|
|
|
|
|
2011-08-07 21:03:19 +02:00
|
|
|
enum_<torrent_handle::status_flags_t>("status_flags_t")
|
|
|
|
.value("query_distributed_copies", torrent_handle::query_distributed_copies)
|
|
|
|
.value("query_accurate_download_counters", torrent_handle::query_accurate_download_counters)
|
|
|
|
.value("query_last_seen_complete", torrent_handle::query_last_seen_complete)
|
|
|
|
.value("query_pieces", torrent_handle::query_pieces)
|
|
|
|
.value("query_verified_pieces", torrent_handle::query_verified_pieces)
|
|
|
|
;
|
2015-09-30 01:17:28 +02:00
|
|
|
|
|
|
|
enum_<move_flags_t>("move_flags_t")
|
|
|
|
.value("always_replace_files", always_replace_files)
|
|
|
|
.value("fail_if_exist", fail_if_exist)
|
|
|
|
.value("dont_replace", dont_replace)
|
|
|
|
;
|
2007-01-10 17:11:43 +01:00
|
|
|
}
|
2016-06-19 01:24:27 +02:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|