Commit b598876c authored by tokar's avatar tokar
Browse files

magnet support in the worker

parent 2e42ee4b
......@@ -88,6 +88,8 @@ auto get_feed_data(string url)
{
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
/* send all data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_memory_callback);
/* we pass our 'chunk' struct to the callback function */
......@@ -146,6 +148,18 @@ uint64_t download_torrents(const string & outdir, const vector<torrent_t> & resu
{
downloads.emplace_back(async(launch::async, [outdir, torrent, &num_torrents]()
{
// is this a magnet ?
cout << "url: "<< torrent.url << endl;
if(torrent.url.substr(0,7) == "magnet:")
{
ofstream magnet_file(outdir+torrent.name+".magnet");
magnet_file.write(torrent.url.c_str(), torrent.url.size());
magnet_file.close();
num_torrents.fetch_add(1);
return;
}
dd_stream ddos;
ddos.outstream = make_shared<ofstream>(outdir+torrent.name);
CURLcode res = CURLE_OK;
......@@ -244,6 +258,7 @@ int main(int argc, char ** argv)
if(verbose)
{
cout << "-- Feed Data: " << feed_data.size() << " bytes --\n";
//cout << "-- Feed Content: " << feed_data << "\n";
}
if(feed_data.empty())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment