Last active
August 29, 2015 14:03
-
-
Save benwaffle/40853a86be7bda00955a to your computer and use it in GitHub Desktop.
simple torrent downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CC=g++ | |
| CFLAGS= | |
| LDFLAGS=-ltorrent-rasterbar -lpthread -lboost_system | |
| all: | |
| $(CC) $(CFLAGS) $(LDFLAGS) -o test test.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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