premiere-libtorrent/bindings/python/src/magnet_uri.cpp

51 lines
1.3 KiB
C++
Raw Normal View History

2008-09-09 16:03:35 +02:00
// Copyright Andrew Resch 2008. 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
2009-03-02 06:23:25 +01:00
#include <boost/python.hpp>
2008-09-09 16:03:35 +02:00
#include <libtorrent/session.hpp>
#include <libtorrent/torrent.hpp>
#include <libtorrent/magnet_uri.hpp>
#include "gil.hpp"
using namespace boost::python;
using namespace libtorrent;
extern void dict_to_add_torrent_params(dict params
2012-10-19 07:18:48 +02:00
, add_torrent_params& p, std::vector<char>& rd);
2008-09-09 16:03:35 +02:00
namespace {
#ifndef TORRENT_NO_DEPRECATE
2008-09-09 16:03:35 +02:00
torrent_handle _add_magnet_uri(session& s, std::string uri, dict params)
{
add_torrent_params p;
std::vector<char> resume_buf;
2012-10-19 07:18:48 +02:00
dict_to_add_torrent_params(params, p, resume_buf);
allow_threading_guard guard;
2010-08-22 18:45:12 +02:00
#ifndef BOOST_NO_EXCEPTIONS
2008-09-09 16:03:35 +02:00
return add_magnet_uri(s, uri, p);
2010-08-22 18:45:12 +02:00
#else
error_code ec;
2010-08-22 18:45:12 +02:00
return add_magnet_uri(s, uri, p, ec);
#endif
2008-09-09 16:03:35 +02:00
}
#endif
std::string (*make_magnet_uri0)(torrent_handle const&) = make_magnet_uri;
std::string (*make_magnet_uri1)(torrent_info const&) = make_magnet_uri;
2008-09-09 16:03:35 +02:00
}
void bind_magnet_uri()
{
#ifndef TORRENT_NO_DEPRECATE
2008-09-09 16:03:35 +02:00
def("add_magnet_uri", &_add_magnet_uri);
#endif
def("make_magnet_uri", make_magnet_uri0);
def("make_magnet_uri", make_magnet_uri1);
2008-09-09 16:03:35 +02:00
}