add torrent_info::metadata and metadata_size to python bindings
This commit is contained in:
@@ -12,58 +12,61 @@ using namespace libtorrent;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<announce_entry>::const_iterator begin_trackers(torrent_info& i)
|
std::vector<announce_entry>::const_iterator begin_trackers(torrent_info& i)
|
||||||
{
|
{
|
||||||
return i.trackers().begin();
|
return i.trackers().begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<announce_entry>::const_iterator end_trackers(torrent_info& i)
|
std::vector<announce_entry>::const_iterator end_trackers(torrent_info& i)
|
||||||
{
|
{
|
||||||
return i.trackers().end();
|
return i.trackers().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_node(torrent_info& ti, char const* hostname, int port)
|
void add_node(torrent_info& ti, char const* hostname, int port)
|
||||||
{
|
{
|
||||||
ti.add_node(std::make_pair(hostname, port));
|
ti.add_node(std::make_pair(hostname, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
list nodes(torrent_info const& ti)
|
list nodes(torrent_info const& ti)
|
||||||
{
|
{
|
||||||
list result;
|
list result;
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, int> > list_type;
|
typedef std::vector<std::pair<std::string, int> > list_type;
|
||||||
|
|
||||||
for (list_type::const_iterator i = ti.nodes().begin(); i != ti.nodes().end(); ++i)
|
for (list_type::const_iterator i = ti.nodes().begin(); i != ti.nodes().end(); ++i)
|
||||||
{
|
{
|
||||||
result.append(make_tuple(i->first, i->second));
|
result.append(make_tuple(i->first, i->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_storage::iterator begin_files(torrent_info& i)
|
file_storage::iterator begin_files(torrent_info& i)
|
||||||
{
|
{
|
||||||
return i.begin_files();
|
return i.begin_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_storage::iterator end_files(torrent_info& i)
|
file_storage::iterator end_files(torrent_info& i)
|
||||||
{
|
{
|
||||||
return i.end_files();
|
return i.end_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
//list files(torrent_info const& ti, bool storage) {
|
//list files(torrent_info const& ti, bool storage) {
|
||||||
list files(torrent_info const& ti, bool storage) {
|
list files(torrent_info const& ti, bool storage) {
|
||||||
list result;
|
list result;
|
||||||
|
|
||||||
typedef std::vector<file_entry> list_type;
|
typedef std::vector<file_entry> list_type;
|
||||||
|
|
||||||
for (list_type::const_iterator i = ti.begin_files(); i != ti.end_files(); ++i)
|
for (list_type::const_iterator i = ti.begin_files(); i != ti.end_files(); ++i)
|
||||||
result.append(*i);
|
result.append(*i);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string metadata(torrent_info const& ti) {
|
||||||
|
std::string result(ti.metadata().get(), ti.metadata_size());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
} // namespace unnamed
|
} // namespace unnamed
|
||||||
|
|
||||||
void bind_torrent_info()
|
void bind_torrent_info()
|
||||||
@@ -101,6 +104,8 @@ void bind_torrent_info()
|
|||||||
|
|
||||||
.def("add_node", &add_node)
|
.def("add_node", &add_node)
|
||||||
.def("nodes", &nodes)
|
.def("nodes", &nodes)
|
||||||
|
.def("metadata", &metadata)
|
||||||
|
.def("metadata_size", &torrent_info::metadata_size)
|
||||||
;
|
;
|
||||||
|
|
||||||
class_<file_entry>("file_entry")
|
class_<file_entry>("file_entry")
|
||||||
|
Reference in New Issue
Block a user