Search in sources :

Example 1 with SearchType

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

the class ExternalApi method buildBaseSearchRequest.

private SearchRequest buildBaseSearchRequest(NewznabParameters params) {
    SearchType searchType = SearchType.valueOf(params.getT().name());
    SearchRequest searchRequest = searchRequestFactory.getSearchRequest(searchType, SearchSource.API, categoryProvider.fromSearchNewznabCategories(params.getCat(), CategoriesConfig.allCategory), random.nextInt(1000000), params.getOffset(), params.getLimit());
    logger.info("Executing new search");
    searchRequest.setQuery(params.getQ());
    searchRequest.setLimit(params.getLimit());
    searchRequest.setOffset(params.getOffset());
    // Not part of spec
    searchRequest.setMinage(params.getMinage());
    searchRequest.setMaxage(params.getMaxage());
    // Not part of spec
    searchRequest.setMinsize(params.getMinsize());
    // Not part of spec
    searchRequest.setMaxsize(params.getMaxsize());
    searchRequest.setAuthor(params.getAuthor());
    searchRequest.setTitle(params.getTitle());
    searchRequest.setSeason(params.getSeason());
    searchRequest.setEpisode(params.getEp());
    if (params.getCat() != null) {
        searchRequest.getInternalData().setNewznabCategories(params.getCat());
    }
    if (!Strings.isNullOrEmpty(params.getTvdbid())) {
        searchRequest.getIdentifiers().put(IdType.TVDB, params.getTvdbid());
    }
    if (!Strings.isNullOrEmpty(params.getTvmazeid())) {
        searchRequest.getIdentifiers().put(IdType.TVMAZE, params.getTvmazeid());
    }
    if (!Strings.isNullOrEmpty(params.getRid())) {
        searchRequest.getIdentifiers().put(IdType.TVRAGE, params.getRid());
    }
    if (!Strings.isNullOrEmpty(params.getImdbid())) {
        searchRequest.getIdentifiers().put(IdType.IMDB, params.getImdbid());
    }
    if (!Strings.isNullOrEmpty(params.getTmdbid())) {
        searchRequest.getIdentifiers().put(IdType.TMDB, params.getTmdbid());
    }
    searchRequest = searchRequestFactory.extendWithSavedIdentifiers(searchRequest);
    return searchRequest;
}
Also used : SearchRequest(org.nzbhydra.searching.searchrequests.SearchRequest) SearchType(org.nzbhydra.searching.SearchType)

Aggregations

SearchType (org.nzbhydra.searching.SearchType)1 SearchRequest (org.nzbhydra.searching.searchrequests.SearchRequest)1