use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class TorrentListViewsUtils method downloadDataSource.
public static void downloadDataSource(Object ds, boolean playNow, String referal) {
TOTorrent torrent = DataSourceUtils.getTorrent(ds);
if (torrent != null) {
// handle encapsulated vuze file
try {
Map torrent_map = torrent.serialiseToMap();
torrent_map.remove("info");
VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile(torrent_map);
if (vf != null) {
VuzeFileHandler.getSingleton().handleFiles(new VuzeFile[] { vf }, VuzeFileComponent.COMP_TYPE_NONE);
return;
}
} catch (Throwable e) {
}
}
// one is likely stale
if (torrent != null) {
TorrentUIUtilsV3.addTorrentToGM(torrent);
} else {
DownloadUrlInfo dlInfo = DataSourceUtils.getDownloadInfo(ds);
if (dlInfo != null) {
TorrentUIUtilsV3.loadTorrent(dlInfo, playNow, false, true);
return;
}
String hash = DataSourceUtils.getHash(ds);
if (hash != null) {
dlInfo = new DownloadUrlInfo(UrlUtils.parseTextForMagnets(hash));
dlInfo.setReferer(referal);
TorrentUIUtilsV3.loadTorrent(dlInfo, playNow, false, true);
return;
}
}
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class SubscriptionManagerImpl method subscribeToSubscription.
@Override
public Subscription subscribeToSubscription(String uri) throws Exception {
SubscriptionManager manager = SubscriptionManagerFactory.getSingleton();
Subscription subs = manager.createFromURI(uri);
if (!subs.isSubscribed()) {
subs.setSubscribed(true);
}
if (subs.isSearchTemplate()) {
try {
VuzeFile vf = subs.getSearchTemplateVuzeFile();
if (vf != null) {
VuzeFileHandler.getSingleton().handleFiles(new VuzeFile[] { vf }, VuzeFileComponent.COMP_TYPE_NONE);
for (VuzeFileComponent comp : vf.getComponents()) {
Engine engine = (Engine) comp.getData(Engine.VUZE_FILE_COMPONENT_ENGINE_KEY);
if (engine != null && (engine.getSelectionState() == Engine.SEL_STATE_DESELECTED || engine.getSelectionState() == Engine.SEL_STATE_FORCE_DESELECTED)) {
engine.setSelectionState(Engine.SEL_STATE_MANUAL_SELECTED);
}
}
}
} catch (Throwable e) {
Debug.out(e);
}
} else {
subs.requestAttention();
}
return (subs);
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class SubscriptionManagerImpl method getSubscriptionFromVuzeFile.
protected SubscriptionImpl getSubscriptionFromVuzeFile(byte[] sid, int add_type, File file) throws SubscriptionException {
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
String file_str = file.getAbsolutePath();
VuzeFile vf = vfh.loadVuzeFile(file_str);
if (vf == null) {
log("Failed to load vuze file from " + file_str);
throw (new SubscriptionException("Failed to load vuze file from " + file_str));
}
return (getSubscriptionFromVuzeFile(sid, add_type, vf));
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class SubscriptionManagerImpl method getSubscriptionFromVuzeFileContent.
protected SubscriptionImpl getSubscriptionFromVuzeFileContent(byte[] sid, int add_type, String content) throws SubscriptionException {
VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
VuzeFile vf = vfh.loadVuzeFile(Base64.decode(content));
if (vf == null) {
log("Failed to load vuze file from " + content);
throw (new SubscriptionException("Failed to load vuze file from content"));
}
return (getSubscriptionFromVuzeFile(sid, add_type, vf));
}
use of com.biglybt.core.vuzefile.VuzeFile in project BiglyBT by BiglySoftware.
the class SubscriptionManagerImpl method getSearchTemplateVuzeFile.
protected Object[] getSearchTemplateVuzeFile(SubscriptionImpl sub) {
try {
String subs_url_str = ((RSSEngine) sub.getEngine()).getSearchUrl(true);
URL subs_url = new URL(subs_url_str);
final byte[] vf_bytes = FileUtil.readInputStreamAsByteArray(subs_url.openConnection().getInputStream());
VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile(vf_bytes);
if (MetaSearchManagerFactory.getSingleton().isImportable(vf)) {
return (new Object[] { vf, vf_bytes });
}
} catch (Throwable e) {
Debug.out(e);
}
return (null);
}
Aggregations