Search in sources :

Example 1 with MovieInfo

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;
}
Also used : TvInfo(org.nzbhydra.mediainfo.TvInfo) MovieInfo(org.nzbhydra.mediainfo.MovieInfo)

Example 2 with MovieInfo

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) MovieInfo(org.nzbhydra.mediainfo.MovieInfo) Test(org.junit.Test) AbstractConfigReplacingTest(org.nzbhydra.tests.AbstractConfigReplacingTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with MovieInfo

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) MovieInfo(org.nzbhydra.mediainfo.MovieInfo) Test(org.junit.Test) AbstractConfigReplacingTest(org.nzbhydra.tests.AbstractConfigReplacingTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MovieInfo (org.nzbhydra.mediainfo.MovieInfo)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 Test (org.junit.Test)2 NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)2 MediaInfo (org.nzbhydra.mediainfo.MediaInfo)2 AbstractConfigReplacingTest (org.nzbhydra.tests.AbstractConfigReplacingTest)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 TvInfo (org.nzbhydra.mediainfo.TvInfo)1