use of org.nzbhydra.mediainfo.MovieInfo in project nzbhydra2 by theotherp.
the class SearchRequestFactory method extendWithSavedIdentifiers.
public SearchRequest extendWithSavedIdentifiers(SearchRequest request) {
if (!request.getIdentifiers().isEmpty()) {
if (request.getIdentifiers().keySet().stream().anyMatch(x -> InfoProvider.TV_ID_TYPES.contains(x))) {
TvInfo tvInfo = infoProvider.findTvInfoInDatabase(request.getIdentifiers());
if (tvInfo != null) {
request.getIdentifiers().put(IdType.TVDB, tvInfo.getTvdbId());
request.getIdentifiers().put(IdType.TVMAZE, tvInfo.getTvmazeId());
request.getIdentifiers().put(IdType.TVRAGE, tvInfo.getTvrageId());
}
}
if (request.getIdentifiers().keySet().stream().anyMatch(x -> InfoProvider.MOVIE_ID_TYPES.contains(x))) {
MovieInfo movieInfo = infoProvider.findMovieInfoInDatabase(request.getIdentifiers());
if (movieInfo != null) {
request.getIdentifiers().put(IdType.TMDB, movieInfo.getTmdbId());
request.getIdentifiers().put(IdType.IMDB, movieInfo.getImdbId());
}
}
}
return request;
}
use of org.nzbhydra.mediainfo.MovieInfo in project nzbhydra2 by theotherp.
the class ExternalApiSearchingIntegrationTest method shouldGenerateQuery.
@Test
public void shouldGenerateQuery() throws Exception {
prepareIndexerWithOneResponse();
configProvider.getBaseConfig().getSearching().setGenerateQueries(SearchSourceRestriction.API);
searchModuleProvider.getIndexers().get(0).getConfig().setSupportedSearchIds(Collections.emptyList());
when(infoProvider.convert(anyMap())).thenReturn(new MediaInfo(new MovieInfo(null, null, "title", 0, null)));
when(infoProvider.convert(any(), any())).thenReturn(new MediaInfo(new MovieInfo(null, null, "title", 0, null)));
when(infoProvider.canConvertAny(anySet(), anySet())).thenReturn(false);
NewznabXmlRoot root = (NewznabXmlRoot) externalApi.api(NewznabParameters.builder().tmdbid("abcd").t(ActionAttribute.MOVIE).apikey("apikey").build()).getBody();
RecordedRequest request = webServer.takeRequest(2, TimeUnit.SECONDS);
assertThat(request.getRequestUrl().queryParameter("q")).isEqualTo("title");
assertThat(root.getRssChannel().getNewznabResponse().getTotal()).isEqualTo(1);
assertThat(root.getRssChannel().getItems().size()).isEqualTo(1);
}
use of org.nzbhydra.mediainfo.MovieInfo in project nzbhydra2 by theotherp.
the class ExternalApiSearchingIntegrationTest method shouldConvertProvidedIdentifier.
@Test
public void shouldConvertProvidedIdentifier() throws Exception {
prepareIndexerWithOneResponse();
searchModuleProvider.getIndexers().get(0).getConfig().setSupportedSearchIds(Arrays.asList(IdType.IMDB));
when(infoProvider.convert(anyMap())).thenReturn(new MediaInfo(new MovieInfo("tt1234", null, null, 0, null)));
when(infoProvider.canConvertAny(anySet(), anySet())).thenReturn(true);
NewznabXmlRoot root = (NewznabXmlRoot) externalApi.api(NewznabParameters.builder().tmdbid("abcd").t(ActionAttribute.MOVIE).apikey("apikey").build()).getBody();
RecordedRequest request = webServer.takeRequest(2, TimeUnit.SECONDS);
assertThat(request.getRequestUrl().queryParameter("imdbid")).isEqualTo("1234");
assertThat(root.getRssChannel().getNewznabResponse().getTotal()).isEqualTo(1);
assertThat(root.getRssChannel().getItems().size()).isEqualTo(1);
}
Aggregations