Skip to content

Instantly share code, notes, and snippets.

@benwaffle
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save benwaffle/40853a86be7bda00955a to your computer and use it in GitHub Desktop.

Select an option

Save benwaffle/40853a86be7bda00955a to your computer and use it in GitHub Desktop.
simple torrent downloader
CC=g++
CFLAGS=
LDFLAGS=-ltorrent-rasterbar -lpthread -lboost_system
all:
$(CC) $(CFLAGS) $(LDFLAGS) -o test test.cpp
#define BOOST_ASIO_DYN_LINK
#include <cstdio>
#include <cstring>
#include <libtorrent/session.hpp>
using namespace libtorrent;
int main(int argc, char **argv)
{
if (argc <= 1) {
fprintf(stderr, "Usage: %s <magnet link / torrent file>\n", argv[0]);
return 1;
}
session s;
s.listen_on(std::make_pair(6881, 6889));
add_torrent_params p;
p.save_path = "./";
if (strstr(argv[1], "magnet:") == argv[1])
p.url = argv[1];
else
p.ti = new torrent_info(argv[1]);
s.add_torrent(p);
char a;
std::cin.unsetf(std::ios_base::skipws);
std::cin >> a;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment