use of com.biglybt.pif.download.DownloadException in project BiglyBT by BiglySoftware.
the class RPShortCuts method getDownloadStats.
@Override
public DownloadStats getDownloadStats(byte[] hash) throws DownloadException {
try {
RPDownloadStats res = (RPDownloadStats) _dispatcher.dispatch(new RPRequest(this, "getDownloadStats[byte[]]", new Object[] { hash })).getResponse();
res._setRemote(_dispatcher);
return (res);
} catch (RPException e) {
if (e.getCause() instanceof DownloadException) {
throw ((DownloadException) e.getCause());
}
throw (e);
}
}
use of com.biglybt.pif.download.DownloadException in project BiglyBT by BiglySoftware.
the class DataSourceUtils method getTorrent.
public static TOTorrent getTorrent(Object ds) {
if (ds instanceof TOTorrent) {
return (TOTorrent) ds;
}
if (ds instanceof DownloadManager) {
TOTorrent torrent = ((DownloadManager) ds).getTorrent();
if (torrent != null) {
return torrent;
}
}
if (ds instanceof ActivitiesEntry) {
TOTorrent torrent = ((ActivitiesEntry) ds).getTorrent();
if (torrent == null) {
// getDM will check hash as well
DownloadManager dm = getDM(ds);
if (dm != null) {
torrent = dm.getTorrent();
}
}
return torrent;
}
if (ds instanceof TranscodeFile) {
TranscodeFile tf = (TranscodeFile) ds;
try {
DiskManagerFileInfo file = tf.getSourceFile();
if (file != null) {
Download download = file.getDownload();
if (download != null) {
Torrent torrent = download.getTorrent();
if (torrent != null) {
return PluginCoreUtils.unwrap(torrent);
}
}
}
} catch (Throwable e) {
}
}
if (ds instanceof TranscodeJob) {
TranscodeJob tj = (TranscodeJob) ds;
try {
DiskManagerFileInfo file = tj.getFile();
if (file != null) {
Download download = tj.getFile().getDownload();
if (download != null) {
Torrent torrent = download.getTorrent();
if (torrent != null) {
return PluginCoreUtils.unwrap(torrent);
}
}
}
} catch (DownloadException e) {
}
}
if (ds instanceof ISelectedContent) {
return ((ISelectedContent) ds).getTorrent();
}
if (ds instanceof String) {
String hash = (String) ds;
try {
GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
if (dm != null) {
return dm.getTorrent();
}
} catch (Exception e) {
// ignore
}
}
DownloadManager dm = getDM(ds);
if (dm != null) {
return dm.getTorrent();
}
return null;
}
use of com.biglybt.pif.download.DownloadException in project BiglyBT by BiglySoftware.
the class TranscodeFileImpl method getName.
@Override
public String getName() {
TranscodeJob job = getJob();
String text;
if (job == null) {
try {
DiskManagerFileInfo sourceFile = getSourceFile();
try {
Download download = sourceFile.getDownload();
if (download == null) {
text = sourceFile.getFile().getName();
} else {
text = download.getName();
DiskManagerFileInfo[] fileInfo = download.getDiskManagerFileInfo();
if (fileInfo.length > 1) {
text += ": " + sourceFile.getFile(true).getName();
}
}
} catch (DownloadException e) {
text = sourceFile.getFile().getName();
}
} catch (Throwable e) {
text = "";
}
} else {
text = job.getName();
}
return (text);
}
use of com.biglybt.pif.download.DownloadException in project BiglyBT by BiglySoftware.
the class TranscodeJobImpl method toMap.
protected Map<String, Object> toMap() throws IOException {
try {
Map<String, Object> map = new HashMap<>();
synchronized (this) {
MapUtils.exportInt(map, "state", state);
MapUtils.setMapString(map, "error", error);
MapUtils.setMapString(map, "target", target.getID());
MapUtils.setMapString(map, "profile", profile.getUID());
try {
Download download = file.getDownload();
MapUtils.setMapString(map, "dl_hash", ByteFormatter.encodeString(download.getTorrent().getHash()));
MapUtils.exportInt(map, "file_index", file.getIndex());
} catch (DownloadException e) {
// external file
MapUtils.setMapString(map, "file", file.getFile().getAbsolutePath());
}
MapUtils.exportInt(map, "trans_req", transcode_requirement);
MapUtils.exportBooleanAsLong(map, "ar_enable", auto_retry_enabled);
MapUtils.exportBooleanAsLong(map, "pdi", prefer_direct_input);
}
return (map);
} catch (Throwable e) {
throw (new IOException("Export failed: " + Debug.getNestedExceptionMessage(e)));
}
}
use of com.biglybt.pif.download.DownloadException in project BiglyBT by BiglySoftware.
the class PluginCoreUtils method convert.
public static Object convert(Object datasource, boolean toCore) {
if (datasource instanceof Object[]) {
Object[] array = (Object[]) datasource;
Object[] newArray = new Object[array.length];
for (int i = 0; i < array.length; i++) {
Object o = array[i];
newArray[i] = convert(o, toCore);
}
return newArray;
}
try {
if (toCore) {
if (datasource instanceof com.biglybt.core.download.DownloadManager) {
return datasource;
}
if (datasource instanceof DownloadImpl) {
return ((DownloadImpl) datasource).getDownload();
}
if (datasource instanceof com.biglybt.core.disk.DiskManager) {
return datasource;
}
if (datasource instanceof DiskManagerImpl) {
return ((DiskManagerImpl) datasource).getDiskmanager();
}
if (datasource instanceof PEPeerManager) {
return datasource;
}
if (datasource instanceof PeerManagerImpl) {
return ((PeerManagerImpl) datasource).getDelegate();
}
if (datasource instanceof PEPeer) {
return datasource;
}
if (datasource instanceof PeerImpl) {
return ((PeerImpl) datasource).getPEPeer();
}
if (datasource instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
return datasource;
}
if (datasource instanceof com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) {
return ((com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) datasource).getCore();
}
if (datasource instanceof TRHostTorrent) {
return datasource;
}
if (datasource instanceof TrackerTorrentImpl) {
((TrackerTorrentImpl) datasource).getHostTorrent();
}
} else {
// to PI
if (datasource instanceof com.biglybt.core.download.DownloadManager) {
return wrap((com.biglybt.core.download.DownloadManager) datasource);
}
if (datasource instanceof DownloadImpl) {
return datasource;
}
if (datasource instanceof com.biglybt.core.disk.DiskManager) {
return wrap((com.biglybt.core.disk.DiskManager) datasource);
}
if (datasource instanceof DiskManagerImpl) {
return datasource;
}
if (datasource instanceof PEPeerManager) {
return wrap((PEPeerManager) datasource);
}
if (datasource instanceof PeerManagerImpl) {
return datasource;
}
if (datasource instanceof PEPeer) {
return PeerManagerImpl.getPeerForPEPeer((PEPeer) datasource);
}
if (datasource instanceof Peer) {
return datasource;
}
if (datasource instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (com.biglybt.core.disk.DiskManagerFileInfo) datasource;
if (fileInfo != null) {
try {
DownloadManager dm = fileInfo.getDownloadManager();
return new com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl(dm == null ? null : DownloadManagerImpl.getDownloadStatic(dm), fileInfo);
} catch (DownloadException e) {
/* Ignore */
}
}
}
if (datasource instanceof com.biglybt.pifimpl.local.disk.DiskManagerFileInfoImpl) {
return datasource;
}
if (datasource instanceof TRHostTorrent) {
TRHostTorrent item = (TRHostTorrent) datasource;
return new TrackerTorrentImpl(item);
}
if (datasource instanceof TrackerTorrentImpl) {
return datasource;
}
}
} catch (Throwable t) {
Debug.out(t);
}
return datasource;
}
Aggregations