// 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 #include #include #include #include #include "gil.hpp" using namespace boost::python; using namespace libtorrent; namespace { torrent_handle _add_magnet_uri(session& s, std::string uri, dict params) { add_torrent_params p; std::string url; if (params.has_key("tracker_url")) { url = extract(params["tracker_url"]); p.tracker_url = url.c_str(); } std::string name; if (params.has_key("name")) { name = extract(params["name"]); p.name = name.c_str(); } p.save_path = fs::path(extract(params["save_path"])); std::vector resume_buf; if (params.has_key("resume_data")) { std::string resume = extract(params["resume_data"]); resume_buf.resize(resume.size()); std::memcpy(&resume_buf[0], &resume[0], resume.size()); p.resume_data = &resume_buf; } p.storage_mode = extract(params["storage_mode"]); p.paused = params["paused"]; p.auto_managed = params["auto_managed"]; p.duplicate_is_error = params["duplicate_is_error"]; return add_magnet_uri(s, uri, p); } } void bind_magnet_uri() { def("add_magnet_uri", &_add_magnet_uri); }