Search in sources :

Example 1 with TvInfo

use of org.nzbhydra.mediainfo.TvInfo 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 TvInfo

use of org.nzbhydra.mediainfo.TvInfo in project nzbhydra2 by theotherp.

the class IndexerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(indexerMock.getIndexerEntity()).thenReturn(indexerEntityMock);
    when(indexerMock.getConfig()).thenReturn(indexerConfig);
    when(indexerEntityMock.getName()).thenReturn("indexerName");
    when(indexerMock.getName()).thenReturn("indexerName");
    testee.indexer = indexerEntityMock;
    testee.config = indexerConfig;
    indexerConfig.setTimeout(1);
    baseConfig = new BaseConfig();
    when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
    baseConfig.getSearching().setIdFallbackToQueryGeneration(SearchSourceRestriction.BOTH);
    when(resultAcceptor.acceptResults(anyList(), any(), any())).then(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return new AcceptorResult(invocation.getArgument(0), HashMultiset.create());
        }
    });
    when(infoProviderMock.convert(anyString(), any())).thenReturn(new MediaInfo(new TvInfo("tvdbid", "tvrageid", "tvmazeid", "title", 2017, "")));
    testee = spy(testee);
}
Also used : AcceptorResult(org.nzbhydra.searching.SearchResultAcceptor.AcceptorResult) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TvInfo(org.nzbhydra.mediainfo.TvInfo) BaseConfig(org.nzbhydra.config.BaseConfig) Before(org.junit.Before)

Example 3 with TvInfo

use of org.nzbhydra.mediainfo.TvInfo in project nzbhydra2 by theotherp.

the class IndexerTest method shouldSanitizeQuery.

@Test
public void shouldSanitizeQuery() throws IndexerSearchAbortedException, InfoProviderException {
    when(infoProviderMock.convert(anyString(), any())).thenReturn(new MediaInfo(new TvInfo("tvdbid", "tvrageid", "tvmazeid", "title()':", 2017, "")));
    baseConfig.getSearching().setGenerateQueries(SearchSourceRestriction.BOTH);
    SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100);
    Map<IdType, String> identifiers = new HashMap<>();
    identifiers.put(IdType.IMDB, "123");
    searchRequest.setIdentifiers(identifiers);
    String query = testee.generateQueryIfApplicable(searchRequest, "query");
    assertThat(query, is("title"));
}
Also used : SearchRequest(org.nzbhydra.searching.searchrequests.SearchRequest) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) HashMap(java.util.HashMap) TvInfo(org.nzbhydra.mediainfo.TvInfo) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IdType(org.nzbhydra.mediainfo.InfoProvider.IdType) Test(org.junit.Test)

Aggregations

TvInfo (org.nzbhydra.mediainfo.TvInfo)3 MediaInfo (org.nzbhydra.mediainfo.MediaInfo)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 BaseConfig (org.nzbhydra.config.BaseConfig)1 IdType (org.nzbhydra.mediainfo.InfoProvider.IdType)1 MovieInfo (org.nzbhydra.mediainfo.MovieInfo)1 AcceptorResult (org.nzbhydra.searching.SearchResultAcceptor.AcceptorResult)1 SearchRequest (org.nzbhydra.searching.searchrequests.SearchRequest)1