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;
}
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);
}
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"));
}
Aggregations