07-14-2014, 04:11 PM
(This post was last modified: 07-15-2014, 08:16 AM by jeanpierre92.)
dear people,
I have been trying to torrent a file with the help of magnet links. But without success.
What I have been reading is that you have to add a magnet link to the PluginInterface as it was an URL.
eg:
After this I add all the downloads to a Download Array and when I ask for the amount of items in the array it returns always 0.
How to properly add a new torrent to the download manager? (Magnet link). Or how to fill the downloads array?
This is the whole code where I want to download a torrent:
Can someone please explain me what I am doing wrong or what I am missing.
I tried several java scripts from others but they all failed.
any help would help :D
Thanks in advance,
Jeanpierre
I have been trying to torrent a file with the help of magnet links. But without success.
What I have been reading is that you have to add a magnet link to the PluginInterface as it was an URL.
eg:
Code:
PluginInterface pi = pm.getDefaultPluginInterface();
pi.getDownloadManager().addDownload(new URL("magnet:?xt=urn:btih:...&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Fopen.demonii.com%3A1337"));
How to properly add a new torrent to the download manager? (Magnet link). Or how to fill the downloads array?
This is the whole code where I want to download a torrent:
Code:
public static void main(String args) throws IOException, DownloadException {
Properties props = new Properties();
props.put(PluginManager.PR_DISABLE_NATIVE_SUPPORT, "true");
File az_dir = new File("C:\\Users\\Jeanpierre\\Downloads\\");
props.put(PluginManager.PR_APP_DIRECTORY, az_dir.getAbsolutePath());
props.put(PluginManager.PR_USER_DIRECTORY, az_dir.getAbsolutePath());
File doc_dir = new File("C:\\Users\\Jeanpierre\\Downloads\\Downloads\\");
props.put(PluginManager.PR_DOC_DIRECTORY, doc_dir.getAbsolutePath());
PluginManager pm;
pm = PluginManager.startAzureus(
PluginManager.UI_NONE, props);
final PluginInterface pi = pm.getDefaultPluginInterface();
pi.addListener(
new PluginListener() {
@Override
public void initializationComplete() {
try {
pi.getDownloadManager().addDownload(new URL("magnet:?xt=urn:btih:...&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Fopen.demonii.com%3A1337"));
} catch (DownloadException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
Download downloads = pi.getDownloadManager().getDownloads();
System.out.println(downloads.length);
for (Download d : downloads) {
System.out.println("Download: " + d.getName());
System.out.println("ik kom hier2");
if (d.getName().contains("aws")) {
org.gudy.azureus2.core3.download.DownloadManager dx =
((org.gudy.azureus2.pluginsimpl.local.download.DownloadImpl) d).getDownload();
dx.startDownload();
try {
d.start();
} catch (DownloadException e) {
e.printStackTrace();
}
}
}
}
@Override
public void closedownInitiated() {
System.out.println("closeDownInitiated");
}
@Override
public void closedownComplete() {
System.out.println("closedownComplete");
}
});
}
I tried several java scripts from others but they all failed.
any help would help :D
Thanks in advance,
Jeanpierre