public Download getDownload(String torrentID) { if (torrentID.startsWith(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX)) { torrentID = torrentID.substring(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX.length()); byte[] torrentHash = Base32.decode(torrentID); try { return pluginInterface.getDownloadManager().getDownload(torrentHash); } catch (DownloadException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
protected void testLinks() { plugin_interface .getDownloadManager() .addListener( new DownloadManagerListener() { public void downloadAdded(Download download) { DiskManagerFileInfo[] info = download.getDiskManagerFileInfo(); for (int i = 0; i < info.length; i++) { info[i].setLink(new File("C:\\temp")); } } public void downloadRemoved(Download download) {} }); }
protected void taTest() { try { final TorrentAttribute ta = plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY); ta.addTorrentAttributeListener( new TorrentAttributeListener() { public void event(TorrentAttributeEvent ev) { System.out.println("ev: " + ev.getType() + ", " + ev.getData()); if (ev.getType() == TorrentAttributeEvent.ET_ATTRIBUTE_VALUE_ADDED) { if ("plop".equals(ev.getData())) { ta.removeDefinedValue("plop"); } } } }); ta.addDefinedValue("wibble"); plugin_interface .getDownloadManager() .addListener( new DownloadManagerListener() { public void downloadAdded(Download download) { try { download.setAttribute(ta, "wibble"); } catch (Throwable e) { e.printStackTrace(); } } public void downloadRemoved(Download download) {} }); } catch (Throwable e) { e.printStackTrace(); } }
public Download addChannel(String channelName) { Torrent torrent = getChannelTorrent(channelName); String savePath = plugin_interface.getPluginDirectoryName(); try { File saveDir = new File(savePath, "channels" + File.separator); saveDir.mkdir(); Download dl = plugin_interface.getDownloadManager().addDownload(torrent, null, saveDir); dl.setForceStart(true); File dest = new File(savePath, "channels" + File.separator + channelName); File src = new File(savePath, "channels" + File.separator + "channel"); copyFile(src, dest); controller.addBridge(dl, channelName); return dl; } catch (Exception e) { e.printStackTrace(); } return null; }
public DownloadManager getDownloadManager() { return pluginInterface.getDownloadManager(); }