Re: [libtorrent] Libtorrent 0.15.8 select file to DL
Brought to you by:
arvidn
From: <ar...@cs...> - 2011-11-07 09:12:25
|
Quoting ÐлекÑÐ°Ð½Ð´Ñ ÐовоÑÑлов <no...@to...>: > Hello everyone! > > I use rasterbar libtorrent to download torrent as stream and play on > STB. It's wonderful BT library, thank you so much! Now I try make > downloading one file from torrent. I have torrent with two files: > 1. Goon/kinopoisk.ru-Goon-74991.mp4 - 38'201'816 bytes > 2. Goon/kinopoisk.ru-Goon-81563.mp4 - 17'434'052 bytes > > To test selective downloading I have modify sample simple-client.cpp: > --- > int main (int argc, char* argv[]) > { > using namespace libtorrent; > #if BOOST_VERSION < 103400 > namespace fs = boost::filesystem; > fs::path::default_name_check(fs::no_check); > #endif > > if (argc != 2) > { > std::cerr << "usage: ./simple_client torrent-file\n" > "to stop the client, press return.\n"; > return 1; > } > > session_settings settings; > // optimizing for stream video > settings.disk_cache_algorithm = session_settings::lru; > > session s; > s.set_settings(settings); > s.listen_on(std::make_pair(6881, 6889)); > > add_torrent_params p; > // STB creates files very slow on FAT32 > p.storage_mode = storage_mode_compact; Unfortunately you can't combine compact storage with deselecting files. Set the storage_mode to storage_mode_sparse instead and it should work. > p.save_path = "./"; > > error_code ec; > p.ti = new torrent_info(argv[1], ec); > > if (ec) > { > std::cout << ec.message() << std::endl; > return 1; > } > > torrent_handle handle = s.add_torrent(p, ec); > // get BT as a stream > handle.set_sequential_download(true); > > // ignore this file > handle.file_priority(0, 0); > // file we want > handle.file_priority(1, 7); > > if (ec) > { > std::cerr << ec.message() << std::endl; > return 1; > } > > // wait for the user to end > char a; > std::cin.unsetf(std::ios_base::skipws); > std::cin >> a; > return 0; > } > --- > > After downloading I have only one file: > 1. Goon/kinopoisk.ru-Goon-74991.mp4 - 17'498'112 bytes > > And VLC can't playback it. > > What I do wrong? > How I built libtorrent: > 1. configure --disable-geoip --disable-encryption > 2. make && sudo make install > > Thank you. -- Arvid Norberg |