use of com.frostwire.jlibtorrent.TcpEndpoint in project frostwire by frostwire.
the class BTEngine method download.
public void download(TorrentInfo ti, File saveDir, boolean[] selection, List<TcpEndpoint> peers, boolean dontSaveTorrentFile) {
if (swig() == null) {
return;
}
saveDir = setupSaveDir(saveDir);
if (saveDir == null) {
return;
}
if (selection == null) {
selection = new boolean[ti.numFiles()];
Arrays.fill(selection, true);
}
Priority[] priorities = null;
TorrentHandle th = find(ti.infoHash());
boolean torrentHandleExists = th != null;
if (torrentHandleExists) {
try {
priorities = th.filePriorities();
} catch (Throwable t) {
t.printStackTrace();
}
} else {
priorities = Priority.array(Priority.IGNORE, ti.numFiles());
}
if (priorities != null) {
boolean changed = false;
for (int i = 0; i < selection.length; i++) {
if (selection[i] && i < priorities.length) {
if (priorities[i] == Priority.IGNORE) {
priorities[i] = Priority.NORMAL;
changed = true;
}
}
}
if (!changed) {
// nothing to do
return;
}
}
download(ti, saveDir, priorities, null, peers);
if (!torrentHandleExists) {
saveResumeTorrent(ti);
if (!dontSaveTorrentFile) {
saveTorrent(ti);
}
}
}
use of com.frostwire.jlibtorrent.TcpEndpoint in project frostwire by frostwire.
the class TorrentFetcherDownload method parsePeers.
private static List<TcpEndpoint> parsePeers(String magnet) {
if (magnet == null || magnet.isEmpty() || magnet.startsWith("http")) {
return Collections.emptyList();
}
// TODO: replace this with the public API
error_code ec = new error_code();
add_torrent_params params = add_torrent_params.parse_magnet_uri(magnet, ec);
tcp_endpoint_vector v = params.get_peers();
int size = (int) v.size();
ArrayList<TcpEndpoint> l = new ArrayList<>();
for (int i = 0; i < size; i++) {
l.add(new TcpEndpoint(v.get(i)));
}
return l;
}
Aggregations