Search in sources :

Example 1 with TorrentCrawledSearchResult

use of com.frostwire.search.torrent.TorrentCrawledSearchResult in project frostwire by frostwire.

the class TransferManager method createBittorrentDownload.

private static BittorrentDownload createBittorrentDownload(TransferManager manager, TorrentSearchResult sr) {
    if (sr instanceof TorrentCrawledSearchResult) {
        TorrentCrawledSearchResult torrentCrawledSearchResult = (TorrentCrawledSearchResult) sr;
        BTEngine.getInstance().download(torrentCrawledSearchResult, null, manager.isDeleteStartedTorrentEnabled());
    } else if (sr.getTorrentUrl() != null) {
        return new TorrentFetcherDownload(manager, new TorrentSearchResultInfo(sr));
    }
    return null;
}
Also used : TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult)

Example 2 with TorrentCrawledSearchResult

use of com.frostwire.search.torrent.TorrentCrawledSearchResult in project frostwire by frostwire.

the class PerformersHelper method crawlTorrent.

/**
 * This method is only public allow reuse inside the package search, consider it a private API
 */
public static List<? extends SearchResult> crawlTorrent(SearchPerformer performer, TorrentCrawlableSearchResult sr, byte[] data, boolean detectAlbums) {
    List<TorrentCrawledSearchResult> list = new LinkedList<>();
    if (data == null) {
        return list;
    }
    TorrentInfo ti;
    try {
        ti = TorrentInfo.bdecode(data);
    } catch (Throwable t) {
        // LOG.error("Can't bdecode:\n" + new String(data) + "\n\n");
        throw t;
    }
    int numFiles = ti.numFiles();
    FileStorage fs = ti.files();
    for (int i = 0; !performer.isStopped() && i < numFiles; i++) {
        // TODO: Check for the hidden attribute
        if (fs.padFileAt(i)) {
            continue;
        }
        list.add(new TorrentCrawledSearchResult(sr, ti, i, fs.filePath(i), fs.fileSize(i)));
    }
    if (detectAlbums) {
        List<SearchResult> temp = new LinkedList<>();
        temp.addAll(list);
        temp.addAll(new AlbumCluster().detect(sr, list));
        return temp;
    } else {
        return list;
    }
}
Also used : TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult) FileStorage(com.frostwire.jlibtorrent.FileStorage) TorrentCrawlableSearchResult(com.frostwire.search.torrent.TorrentCrawlableSearchResult) TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult) TorrentInfo(com.frostwire.jlibtorrent.TorrentInfo) LinkedList(java.util.LinkedList)

Example 3 with TorrentCrawledSearchResult

use of com.frostwire.search.torrent.TorrentCrawledSearchResult in project frostwire by frostwire.

the class TorrentUISearchResult method download.

@Override
public void download(boolean partial) {
    GUIMediator gm = GUIMediator.instance();
    gm.openTorrentSearchResult(sr, partial);
    showDetails(false);
    UXStats.instance().log((sr instanceof TorrentCrawledSearchResult) ? UXAction.DOWNLOAD_PARTIAL_TORRENT_FILE : UXAction.DOWNLOAD_FULL_TORRENT_FILE);
}
Also used : GUIMediator(com.limegroup.gnutella.gui.GUIMediator) TorrentCrawledSearchResult(com.frostwire.search.torrent.TorrentCrawledSearchResult)

Aggregations

TorrentCrawledSearchResult (com.frostwire.search.torrent.TorrentCrawledSearchResult)3 FileStorage (com.frostwire.jlibtorrent.FileStorage)1 TorrentInfo (com.frostwire.jlibtorrent.TorrentInfo)1 TorrentCrawlableSearchResult (com.frostwire.search.torrent.TorrentCrawlableSearchResult)1 GUIMediator (com.limegroup.gnutella.gui.GUIMediator)1 LinkedList (java.util.LinkedList)1