Search in sources :

Example 6 with SearchResultEntity

use of org.nzbhydra.searching.SearchResultEntity in project nzbhydra2 by theotherp.

the class FileHandler method getNfo.

public NfoResult getNfo(Long searchResultId) {
    SearchResultEntity result = searchResultRepository.findOne(searchResultId);
    if (result == null) {
        logger.error("Download request with invalid/outdated search result ID " + searchResultId);
        throw new RuntimeException("Download request with invalid/outdated search result ID " + searchResultId);
    }
    Indexer indexer = searchModuleProvider.getIndexerByName(result.getIndexer().getName());
    return indexer.getNfo(result.getIndexerGuid());
}
Also used : Indexer(org.nzbhydra.indexers.Indexer) SearchResultEntity(org.nzbhydra.searching.SearchResultEntity)

Example 7 with SearchResultEntity

use of org.nzbhydra.searching.SearchResultEntity in project nzbhydra2 by theotherp.

the class FileHandler method getFileByGuid.

public DownloadResult getFileByGuid(long guid, FileDownloadAccessType fileDownloadAccessType, SearchSource accessSource) throws InvalidSearchResultIdException {
    SearchResultEntity result = searchResultRepository.findOne(guid);
    if (result == null) {
        logger.error("Download request with invalid/outdated GUID {}", guid);
        throw new InvalidSearchResultIdException(guid, accessSource == SearchSource.INTERNAL);
    }
    String downloadType = result.getDownloadType() == DownloadType.NZB ? "NZB" : "Torrent";
    logger.info("{} download request for \"{}\" from indexer {}", downloadType, result.getTitle(), result.getIndexer().getName());
    if (fileDownloadAccessType == FileDownloadAccessType.REDIRECT) {
        return handleRedirect(accessSource, result);
    } else {
        return handleContentDownload(accessSource, result, downloadType);
    }
}
Also used : SearchResultEntity(org.nzbhydra.searching.SearchResultEntity)

Aggregations

SearchResultEntity (org.nzbhydra.searching.SearchResultEntity)7 Test (org.junit.Test)2 IndexerEntity (org.nzbhydra.indexers.IndexerEntity)2 MoreObjects (com.google.common.base.MoreObjects)1 Stopwatch (com.google.common.base.Stopwatch)1 Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Sets (com.google.common.collect.Sets)1 Instant (java.time.Instant)1 java.util (java.util)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Data (lombok.Data)1 NoArgsConstructor (lombok.NoArgsConstructor)1 Before (org.junit.Before)1 GenericResponse (org.nzbhydra.GenericResponse)1 DownloaderConfig (org.nzbhydra.config.DownloaderConfig)1 FileDownloadAccessType (org.nzbhydra.config.FileDownloadAccessType)1