Search in sources :

Example 1 with VuzeFile

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;
        }
    }
}
Also used : DownloadUrlInfo(com.biglybt.ui.selectedcontent.DownloadUrlInfo) TOTorrent(com.biglybt.core.torrent.TOTorrent) VuzeFile(com.biglybt.core.vuzefile.VuzeFile) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with VuzeFile

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);
}
Also used : VuzeFileComponent(com.biglybt.core.vuzefile.VuzeFileComponent) VuzeFile(com.biglybt.core.vuzefile.VuzeFile) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine) Engine(com.biglybt.core.metasearch.Engine) RSSEngine(com.biglybt.core.metasearch.impl.web.rss.RSSEngine)

Example 3 with VuzeFile

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));
}
Also used : VuzeFile(com.biglybt.core.vuzefile.VuzeFile) VuzeFileHandler(com.biglybt.core.vuzefile.VuzeFileHandler)

Example 4 with VuzeFile

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));
}
Also used : VuzeFile(com.biglybt.core.vuzefile.VuzeFile) VuzeFileHandler(com.biglybt.core.vuzefile.VuzeFileHandler)

Example 5 with VuzeFile

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);
}
Also used : VuzeFile(com.biglybt.core.vuzefile.VuzeFile) RSSEngine(com.biglybt.core.metasearch.impl.web.rss.RSSEngine) URL(java.net.URL)

Aggregations

VuzeFile (com.biglybt.core.vuzefile.VuzeFile)36 File (java.io.File)12 VuzeFileHandler (com.biglybt.core.vuzefile.VuzeFileHandler)10 VuzeFileComponent (com.biglybt.core.vuzefile.VuzeFileComponent)9 URL (java.net.URL)9 RSSEngine (com.biglybt.core.metasearch.impl.web.rss.RSSEngine)5 TOTorrent (com.biglybt.core.torrent.TOTorrent)5 IOException (java.io.IOException)5 PluginEngine (com.biglybt.core.metasearch.impl.plugin.PluginEngine)4 WebEngine (com.biglybt.core.metasearch.impl.web.WebEngine)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Map (java.util.Map)4 Subscription (com.biglybt.core.subs.Subscription)3 VuzeFileProcessor (com.biglybt.core.vuzefile.VuzeFileProcessor)3 UIManager (com.biglybt.pif.ui.UIManager)3 Engine (com.biglybt.core.metasearch.Engine)2 SubscriptionException (com.biglybt.core.subs.SubscriptionException)2 ResourceDownloader (com.biglybt.pif.utils.resourcedownloader.ResourceDownloader)2 ResourceDownloaderFactory (com.biglybt.pif.utils.resourcedownloader.ResourceDownloaderFactory)2 InputStream (java.io.InputStream)2