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

41 lines
1.1 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
, add_torrent_params& p, std::vector<char>& rd
, std::list<std::string>& storage);
2008-09-09 16:03:35 +02:00
namespace {
torrent_handle _add_magnet_uri(session& s, std::string uri, dict params)
{
add_torrent_params p;
std::vector<char> resume_buf;
std::list<std::string> string_storage;
dict_to_add_torrent_params(params, p, resume_buf, string_storage);
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
}
}
void bind_magnet_uri()
{
def("add_magnet_uri", &_add_magnet_uri);
}