use of com.frostwire.android.core.MediaType in project frostwire by frostwire.
the class Librarian method getFileType.
private byte getFileType(String filename, boolean returnTorrentsAsDocument) {
byte result = Constants.FILE_TYPE_DOCUMENTS;
MediaType mt = MediaType.getMediaTypeForExtension(FilenameUtils.getExtension(filename));
if (mt != null) {
result = (byte) mt.getId();
}
if (returnTorrentsAsDocument && result == Constants.FILE_TYPE_TORRENTS) {
result = Constants.FILE_TYPE_DOCUMENTS;
}
return result;
}
use of com.frostwire.android.core.MediaType in project frostwire by frostwire.
the class SearchResultListAdapter method filter.
public FilteredSearchResults filter(List<SearchResult> results) {
FilteredSearchResults fsr = new FilteredSearchResults();
ArrayList<SearchResult> mediaTypedFiltered = new ArrayList<>();
ArrayList<SearchResult> keywordFiltered = new ArrayList<>();
List<KeywordFilter> keywordFilters = getKeywordFiltersPipeline();
for (SearchResult sr : results) {
String extension = FilenameUtils.getExtension(((FileSearchResult) sr).getFilename());
MediaType mt = MediaType.getMediaTypeForExtension(extension);
if ("youtube".equals(extension)) {
mt = MediaType.getVideoMediaType();
} else if (mt != null && mt.equals(MediaType.getVideoMediaType()) && sr instanceof YouTubeCrawledSearchResult) {
// NOTE: this excludes all non .youtube youtube search results (e.g. 3gp, webm) from appearing on results
mt = null;
}
boolean passedKeywordFilter = KeywordFilter.passesFilterPipeline(sr, keywordFilters);
if (isFileSearchResultMediaTypeMatching(sr, mt)) {
if (keywordFilters.isEmpty() || passedKeywordFilter) {
mediaTypedFiltered.add(sr);
keywordFiltered.add(sr);
}
} else if (mt != null && passedKeywordFilter) {
keywordFiltered.add(sr);
}
fsr.increment(mt, passedKeywordFilter);
}
fsr.filtered = mediaTypedFiltered;
fsr.keywordFiltered = keywordFiltered;
return fsr;
}
Aggregations