Search in sources :

Example 6 with SearchResult

use of com.frostwire.search.SearchResult in project frostwire by frostwire.

the class SearchTableTest method testAddSingleListener.

@Test
public void testAddSingleListener() {
    SearchTable t = new SearchTable(0);
    final AtomicBoolean b1 = new AtomicBoolean(false);
    final AtomicBoolean b2 = new AtomicBoolean(false);
    SearchView view = t.view(SearchFilter.NONE);
    view.setListener(new SearchViewListener() {

        @Override
        public void viewChanged(SearchView view) {
            b2.set(true);
        }

        @Override
        public void viewAdded(SearchView view, List<SearchResult> results) {
            b1.set(true);
        }
    });
    t.add(new TestSearchResult("a"));
    assertTrue(b1.get());
    t.clear();
    assertTrue(b2.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SearchResult(com.frostwire.search.SearchResult) Test(org.junit.Test)

Example 7 with SearchResult

use of com.frostwire.search.SearchResult in project frostwire by frostwire.

the class SearchResultActionsRenderer method labelPartialDownload_mouseReleased.

private void labelPartialDownload_mouseReleased(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        SearchResult sr = searchResult.getSearchResult();
        if (sr instanceof CrawlableSearchResult || sr instanceof ArchiveorgTorrentSearchResult) {
            searchResult.download(true);
            UXStats.instance().log(UXAction.SEARCH_RESULT_DETAIL_VIEW);
            if (sr instanceof ArchiveorgTorrentSearchResult) {
                GUIMediator.instance().showTransfers(TransfersTab.FilterMode.ALL);
            }
        }
    }
}
Also used : ArchiveorgTorrentSearchResult(com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult) SearchResult(com.frostwire.search.SearchResult) StreamableSearchResult(com.frostwire.search.StreamableSearchResult) CrawlableSearchResult(com.frostwire.search.CrawlableSearchResult) ArchiveorgTorrentSearchResult(com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult) CrawlableSearchResult(com.frostwire.search.CrawlableSearchResult)

Example 8 with SearchResult

use of com.frostwire.search.SearchResult in project frostwire by frostwire.

the class YouTubeSearchPerformer method crawlResult.

@Override
protected List<? extends SearchResult> crawlResult(YouTubeSearchResult sr, byte[] data) throws Exception {
    List<SearchResult> list = new LinkedList<>();
    String detailsUrl = sr.getDetailsUrl();
    List<LinkInfo> infos = new YouTubeExtractor().extract(detailsUrl, false);
    LinkInfo dashVideo = null;
    LinkInfo dashAudio = null;
    LinkInfo demuxVideo = null;
    LinkInfo minQuality = null;
    for (LinkInfo inf : infos) {
        if (inf.fmt == 18) {
            // save this format for the heuristic of selecting audio
            // from dash or demuxing a video one
            demuxVideo = inf;
        }
        if (!isDash(inf)) {
            if (inf.fmt == 18) {
                minQuality = inf;
            }
            list.add(new YouTubeCrawledStreamableSearchResult(sr, inf, null, minQuality));
        } else {
            if (inf.fmt == 137) {
                // 1080p
                dashVideo = inf;
            }
            if (inf.fmt == 141) {
                // 256k
                dashAudio = inf;
            }
            if (inf.fmt == 140 && dashAudio == null) {
                // 128k
                dashAudio = inf;
            }
        }
    }
    if (dashVideo != null && dashAudio != null) {
        list.add(new YouTubeCrawledSearchResult(sr, dashVideo, dashAudio));
    }
    LinkInfo infoAudio = selectFormatForAudio(sr, dashAudio, demuxVideo);
    if (infoAudio != null) {
        list.add(new YouTubeCrawledStreamableSearchResult(sr, null, infoAudio, minQuality));
    }
    YouTubePackageSearchResult packagedResult = new YouTubePackageSearchResult(sr, list);
    List<SearchResult> results = new LinkedList<>();
    results.add(packagedResult);
    results.addAll(list);
    return results;
}
Also used : SearchResult(com.frostwire.search.SearchResult) LinkInfo(com.frostwire.search.youtube.YouTubeExtractor.LinkInfo) LinkedList(java.util.LinkedList)

Example 9 with SearchResult

use of com.frostwire.search.SearchResult in project frostwire by frostwire.

the class SearchResultActionsRenderer method updateUIData.

private void updateUIData(SearchResultActionsHolder actionsHolder, JTable table, int row) {
    cancelEdit();
    if (actionsHolder == null) {
        return;
    }
    searchResult = actionsHolder.getSearchResult();
    if (searchResult == null) {
        return;
    }
    showSolid = mouseIsOverRow(table, row);
    labelPlay.setVisible(isSearchResultPlayable());
    if (labelPlay.isVisible()) {
        updatePlayButton();
    }
    labelDownload.setIcon(showSolid ? download_solid : download_transparent);
    labelDownload.setVisible(true);
    labelPartialDownload.setIcon(showSolid ? details_solid : details_transparent);
    SearchResult sr = searchResult.getSearchResult();
    labelPartialDownload.setVisible(sr instanceof CrawlableSearchResult || sr instanceof ArchiveorgTorrentSearchResult);
}
Also used : ArchiveorgTorrentSearchResult(com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult) SearchResult(com.frostwire.search.SearchResult) StreamableSearchResult(com.frostwire.search.StreamableSearchResult) CrawlableSearchResult(com.frostwire.search.CrawlableSearchResult) ArchiveorgTorrentSearchResult(com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult) CrawlableSearchResult(com.frostwire.search.CrawlableSearchResult)

Example 10 with SearchResult

use of com.frostwire.search.SearchResult in project frostwire by frostwire.

the class SearchResultMediator method buildListeners.

/**
 * Sets all the listeners.
 */
protected void buildListeners() {
    super.buildListeners();
    DOWNLOAD_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e != null && e.getSource() instanceof JButton) {
                UXStats.instance().log(UXAction.SEARCH_RESULT_BIG_BUTTON_DOWNLOAD);
            }
            SearchMediator.doDownload(SearchResultMediator.this);
        }
    };
    TORRENT_DETAILS_LISTENER = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final SearchResultDataLine[] lines = getAllSelectedLines();
                if (lines.length == 1) {
                    UISearchResult searchResult = lines[0].getSearchResult();
                    searchResult.showDetails(true);
                }
            }
        }
    };
    COPY_MAGNET_ACTION_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            StringBuilder sb = new StringBuilder();
            for (SearchResultDataLine line : lines) {
                sb.append(TorrentUtil.getMagnet(line.getInitializeObject()));
                sb.append("\n");
            }
            GUIMediator.setClipboardContent(sb.toString());
        }
    };
    COPY_HASH_ACTION_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            StringBuilder sb = new StringBuilder();
            for (SearchResultDataLine line : lines) {
                sb.append(line.getInitializeObject().getHash());
                sb.append("\n");
            }
            GUIMediator.setClipboardContent(sb.toString());
        }
    };
    CONFIGURE_SHARING_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            GUIMediator.instance().setOptionsVisible(true, tr("Options"));
        }
    };
    DOWNLOAD_PARTIAL_FILES_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            if (lines.length == 1 && lines[0] != null) {
                final SearchResult sr = lines[0].getInitializeObject().getSearchResult();
                if (sr instanceof TorrentSearchResult) {
                    // GUIMediator gm = GUIMediator.instance();
                    // if (sr instanceof ScrapedTorrentFileSearchResult) {
                    // gm.openTorrentSearchResult((ScrapedTorrentFileSearchResult) sr);
                    // } else {
                    GUIMediator.instance().openTorrentSearchResult((TorrentSearchResult) sr, true);
                // }
                }
            }
        }
    };
    STOP_SEARCH_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchMediator.instance().stopSearch(token);
            updateSearchIcon(false);
            setButtonEnabled(SearchButtons.STOP_SEARCH_BUTTON_INDEX, false);
        }
    };
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SearchResult(com.frostwire.search.SearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult)

Aggregations

SearchResult (com.frostwire.search.SearchResult)14 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)6 FileSearchResult (com.frostwire.search.FileSearchResult)5 StreamableSearchResult (com.frostwire.search.StreamableSearchResult)4 HttpSlideSearchResult (com.frostwire.android.gui.transfers.HttpSlideSearchResult)3 TorrentPromotionSearchResult (com.frostwire.frostclick.TorrentPromotionSearchResult)3 HttpSearchResult (com.frostwire.search.HttpSearchResult)3 SoundcloudSearchResult (com.frostwire.search.soundcloud.SoundcloudSearchResult)3 AbstractTorrentSearchResult (com.frostwire.search.torrent.AbstractTorrentSearchResult)3 TorrentCrawledSearchResult (com.frostwire.search.torrent.TorrentCrawledSearchResult)3 YouTubeCrawledSearchResult (com.frostwire.search.youtube.YouTubeCrawledSearchResult)3 YouTubeCrawledStreamableSearchResult (com.frostwire.search.youtube.YouTubeCrawledStreamableSearchResult)3 YouTubePackageSearchResult (com.frostwire.search.youtube.YouTubePackageSearchResult)3 YouTubeSearchResult (com.frostwire.search.youtube.YouTubeSearchResult)3 CrawlableSearchResult (com.frostwire.search.CrawlableSearchResult)2 ArchiveorgTorrentSearchResult (com.frostwire.search.archiveorg.ArchiveorgTorrentSearchResult)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Intent (android.content.Intent)1 MediaType (com.frostwire.android.core.MediaType)1