Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
torrent file with magnet link
#1
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:


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"));
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:
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");
}
});
}
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

 

 

 
#2
magnet links are downloaded asynchronously and can take some time to complete (if they complete at all..) A better way to manage this process is to use the plugin interface TorrentManager methods to get a TorrentDownloader for the magnet, then call download() to attempt to download the torrent, then if successful you can add the Torrent using the DownloadManager addDownload( Torrent ) method(s)


Possibly Related Threads...
Thread Author Replies Views Last Post
  Is there a way to change the Status/Link time delay in RSSFeed Scanner? trgarner 0 52 01-08-2017, 04:30 PM
Last Post: trgarner
  Magnet link downloads won't work 243ms 14 61,736 10-31-2016, 08:07 PM
Last Post: burtonr75



Users browsing this thread: 2 Guest(s)