Search in sources :

Example 1 with SuggestionExtractor

use of org.schabi.newpipe.extractor.SuggestionExtractor in project NewPipe by TeamNewPipe.

the class YoutubeSearchResultTest method setUp.

@Before
public void setUp() throws Exception {
    NewPipe.init(Downloader.getInstance());
    SuggestionExtractor engine = new YoutubeSuggestionExtractor(0);
    suggestionReply = engine.suggestionList("hello", "de");
}
Also used : YoutubeSuggestionExtractor(org.schabi.newpipe.extractor.services.youtube.YoutubeSuggestionExtractor) SuggestionExtractor(org.schabi.newpipe.extractor.SuggestionExtractor) YoutubeSuggestionExtractor(org.schabi.newpipe.extractor.services.youtube.YoutubeSuggestionExtractor) Before(org.junit.Before)

Example 2 with SuggestionExtractor

use of org.schabi.newpipe.extractor.SuggestionExtractor in project NewPipe by TeamNewPipe.

the class SuggestionSearchRunnable method run.

@Override
public void run() {
    try {
        SuggestionExtractor se = NewPipe.getService(serviceId).getSuggestionExtractorInstance();
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(a);
        String searchLanguageKey = a.getString(R.string.search_language_key);
        String searchLanguage = sp.getString(searchLanguageKey, a.getString(R.string.default_language_value));
        List<String> suggestions = se.suggestionList(query, searchLanguage);
        h.post(new SuggestionResultRunnable(suggestions));
    } catch (ExtractionException e) {
        ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content), ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED, NewPipe.getNameOfService(serviceId), query, R.string.parsing_error));
        e.printStackTrace();
    } catch (IOException e) {
        postNewErrorToast(h, R.string.network_error);
        e.printStackTrace();
    } catch (Exception e) {
        ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content), ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED, NewPipe.getNameOfService(serviceId), query, R.string.general_error));
    }
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) SharedPreferences(android.content.SharedPreferences) SuggestionExtractor(org.schabi.newpipe.extractor.SuggestionExtractor) IOException(java.io.IOException) IOException(java.io.IOException) ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException)

Aggregations

SuggestionExtractor (org.schabi.newpipe.extractor.SuggestionExtractor)2 SharedPreferences (android.content.SharedPreferences)1 IOException (java.io.IOException)1 Before (org.junit.Before)1 ExtractionException (org.schabi.newpipe.extractor.exceptions.ExtractionException)1 YoutubeSuggestionExtractor (org.schabi.newpipe.extractor.services.youtube.YoutubeSuggestionExtractor)1