Search in sources :

Example 1 with SubscriptionResult

use of com.biglybt.core.subs.SubscriptionResult in project BiglyBT by BiglySoftware.

the class BuddyPluginViewBetaChat method checkSubscriptions.

private void checkSubscriptions(boolean ftux_change) {
    Subscription[] subs = SubscriptionManagerFactory.getSingleton().getSubscriptions();
    for (Subscription sub : subs) {
        try {
            Engine e = sub.getEngine();
            if (e instanceof WebEngine) {
                String url = ((WebEngine) e).getSearchUrl();
                if (isRSSURL(url, chat)) {
                    if (ftux_change) {
                        SubscriptionResult[] results = sub.getResults(false);
                        for (SubscriptionResult r : results) {
                            Map<Integer, Object> properties = r.toPropertyMap();
                            String name = (String) properties.get(SearchResult.PR_NAME);
                            if (name.equals(BuddyPluginBeta.RSS_ITEMS_UNAVAILABLE)) {
                                r.delete();
                            }
                        }
                    } else {
                        sub.getManager().getScheduler().downloadAsync(sub, true);
                    }
                }
            }
        } catch (Throwable e) {
        }
    }
}
Also used : SubscriptionResult(com.biglybt.core.subs.SubscriptionResult) Subscription(com.biglybt.core.subs.Subscription) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine) Engine(com.biglybt.core.metasearch.Engine) WebEngine(com.biglybt.core.metasearch.impl.web.WebEngine)

Example 2 with SubscriptionResult

use of com.biglybt.core.subs.SubscriptionResult in project BiglyBT by BiglySoftware.

the class MetaSearchListener method encodeResults.

protected void encodeResults(Subscription subs, Map result) {
    JSONArray results_list = new JSONArray();
    SubscriptionResult[] results = subs.getHistory().getResults(false);
    for (int i = 0; i < results.length; i++) {
        SubscriptionResult r = results[i];
        results_list.add(r.toJSONMap());
    }
    result.put("results", results_list);
}
Also used : SubscriptionResult(com.biglybt.core.subs.SubscriptionResult) JSONArray(org.json.simple.JSONArray)

Example 3 with SubscriptionResult

use of com.biglybt.core.subs.SubscriptionResult in project BiglyBT by BiglySoftware.

the class SBC_SubscriptionResultsView method reconcileResults.

private void reconcileResults(Subscription subs) {
    synchronized (this) {
        if (subs != ds || ds == null || subs == null || tv_subs_results == null) {
            return;
        }
        tv_subs_results.processDataSourceQueueSync();
        List<SBC_SubscriptionResult> existing_results = tv_subs_results.getDataSources(true);
        Map<String, SBC_SubscriptionResult> existing_map = new HashMap<>();
        for (SBC_SubscriptionResult result : existing_results) {
            existing_map.put(result.getID(), result);
        }
        SubscriptionResult[] current_results = ds.getResults(false);
        List<SBC_SubscriptionResult> new_results = new ArrayList<>(current_results.length);
        for (SubscriptionResult result : current_results) {
            SBC_SubscriptionResult existing = existing_map.remove(result.getID());
            if (existing == null) {
                new_results.add(new SBC_SubscriptionResult(ds, result));
            } else {
                existing.updateFrom(result);
            }
        }
        if (new_results.size() > 0) {
            tv_subs_results.addDataSources(new_results.toArray(new SBC_SubscriptionResult[new_results.size()]));
        }
        if (existing_map.size() > 0) {
            Collection<SBC_SubscriptionResult> to_remove = existing_map.values();
            tv_subs_results.removeDataSources(to_remove.toArray(new SBC_SubscriptionResult[to_remove.size()]));
        }
    }
}
Also used : SubscriptionResult(com.biglybt.core.subs.SubscriptionResult)

Aggregations

SubscriptionResult (com.biglybt.core.subs.SubscriptionResult)3 Engine (com.biglybt.core.metasearch.Engine)1 WebEngine (com.biglybt.core.metasearch.impl.web.WebEngine)1 Subscription (com.biglybt.core.subs.Subscription)1 JSONArray (org.json.simple.JSONArray)1