use of com.frostwire.search.torrent.TorrentCrawlableSearchResult 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;
}
}
Aggregations