@Test public void shouldNotConvertIdIfNotNecessary() throws Exception { SearchRequest searchRequest = new SearchRequest(SearchSource.INTERNAL, SearchType.SEARCH, 0, 100); searchRequest.getIdentifiers().put(MediaIdType.TMDB, "tmdbId"); testee.extendQueryUrlWithSearchIds(searchRequest, uriComponentsBuilderMock); verify(infoProviderMock, never()).convert(anyString(), eq(MediaIdType.TMDB)); }
protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchRequest, UriComponentsBuilder componentsBuilder) { if (!searchRequest.getIdentifiers().isEmpty()) { Map<MediaIdType, String> params = new HashMap<>(); boolean idConversionNeeded = isIdConversionNeeded(searchRequest); if (idConversionNeeded) { boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds())); if (canConvertAnyId) { try { MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers()); if (info.getImdbId().isPresent()) { if (searchRequest.getSearchType() == SearchType.MOVIE && config.getSupportedSearchIds().contains(MediaIdType.IMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } if (searchRequest.getSearchType() == SearchType.TVSEARCH && config.getSupportedSearchIds().contains(MediaIdType.TVIMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } } if (info.getTmdbId().isPresent()) { params.put(MediaIdType.TMDB, info.getTmdbId().get()); } if (info.getTvRageId().isPresent()) { params.put(MediaIdType.TVRAGE, info.getTvRageId().get()); } if (info.getTvMazeId().isPresent()) { params.put(MediaIdType.TVMAZE, info.getTvMazeId().get()); } if (info.getTvDbId().isPresent()) { params.put(MediaIdType.TVDB, info.getTvDbId().get()); } } catch (InfoProviderException e) { error("Error while converting search ID", e); } } else { debug("Unable to convert any of the provided IDs to any of these supported IDs: {}", Joiner.on(", ").join(config.getSupportedSearchIds())); } if (params.isEmpty()) { warn("Didn't find any usable IDs to add to search request"); } } params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value)); for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) { if (entry.getValue() == null) { continue; } if (!config.getSupportedSearchIds().contains(entry.getKey())) { continue; } componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", "")); } } return componentsBuilder; }
Newznab extends Indexer<Xml> { protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchRequest, UriComponentsBuilder componentsBuilder) { if (!searchRequest.getIdentifiers().isEmpty()) { Map<MediaIdType, String> params = new HashMap<>(); boolean idConversionNeeded = isIdConversionNeeded(searchRequest); if (idConversionNeeded) { boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds())); if (canConvertAnyId) { try { MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers()); if (info.getImdbId().isPresent()) { if (searchRequest.getSearchType() == SearchType.MOVIE && config.getSupportedSearchIds().contains(MediaIdType.IMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } if (searchRequest.getSearchType() == SearchType.TVSEARCH && config.getSupportedSearchIds().contains(MediaIdType.TVIMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } } if (info.getTmdbId().isPresent()) { params.put(MediaIdType.TMDB, info.getTmdbId().get()); } if (info.getTvRageId().isPresent()) { params.put(MediaIdType.TVRAGE, info.getTvRageId().get()); } if (info.getTvMazeId().isPresent()) { params.put(MediaIdType.TVMAZE, info.getTvMazeId().get()); } if (info.getTvDbId().isPresent()) { params.put(MediaIdType.TVDB, info.getTvDbId().get()); } } catch (InfoProviderException e) { error("Error while converting search ID", e); } } else { debug("Unable to convert any of the provided IDs to any of these supported IDs: {}", Joiner.on(", ").join(config.getSupportedSearchIds())); } if (params.isEmpty()) { warn("Didn't find any usable IDs to add to search request"); } } params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value)); for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) { if (entry.getValue() == null) { continue; } if (!config.getSupportedSearchIds().contains(entry.getKey())) { continue; } componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", "")); } } return componentsBuilder; } }
Newznab extends Indexer<Xml> { protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchRequest, UriComponentsBuilder componentsBuilder) { if (!searchRequest.getIdentifiers().isEmpty()) { Map<MediaIdType, String> params = new HashMap<>(); boolean idConversionNeeded = isIdConversionNeeded(searchRequest); if (idConversionNeeded) { boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds())); if (canConvertAnyId) { try { MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers()); if (info.getImdbId().isPresent()) { if (searchRequest.getSearchType() == SearchType.MOVIE && config.getSupportedSearchIds().contains(MediaIdType.IMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } if (searchRequest.getSearchType() == SearchType.TVSEARCH && config.getSupportedSearchIds().contains(MediaIdType.TVIMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } } if (info.getTmdbId().isPresent()) { params.put(MediaIdType.TMDB, info.getTmdbId().get()); } if (info.getTvRageId().isPresent()) { params.put(MediaIdType.TVRAGE, info.getTvRageId().get()); } if (info.getTvMazeId().isPresent()) { params.put(MediaIdType.TVMAZE, info.getTvMazeId().get()); } if (info.getTvDbId().isPresent()) { params.put(MediaIdType.TVDB, info.getTvDbId().get()); } } catch (InfoProviderException e) { error("Error while converting search ID", e); } } else { debug("Unable to convert any of the provided IDs to any of these supported IDs: {}", Joiner.on(", ").join(config.getSupportedSearchIds())); } if (params.isEmpty()) { warn("Didn't find any usable IDs to add to search request"); } } params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value)); for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) { if (entry.getValue() == null) { continue; } if (!config.getSupportedSearchIds().contains(entry.getKey())) { continue; } componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", "")); } } return componentsBuilder; }  }
Newznab extends Indexer<Xml> { protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchRequest, UriComponentsBuilder componentsBuilder) { if (!searchRequest.getIdentifiers().isEmpty()) { Map<MediaIdType, String> params = new HashMap<>(); boolean idConversionNeeded = isIdConversionNeeded(searchRequest); if (idConversionNeeded) { boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds())); if (canConvertAnyId) { try { MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers()); if (info.getImdbId().isPresent()) { if (searchRequest.getSearchType() == SearchType.MOVIE && config.getSupportedSearchIds().contains(MediaIdType.IMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } if (searchRequest.getSearchType() == SearchType.TVSEARCH && config.getSupportedSearchIds().contains(MediaIdType.TVIMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } } if (info.getTmdbId().isPresent()) { params.put(MediaIdType.TMDB, info.getTmdbId().get()); } if (info.getTvRageId().isPresent()) { params.put(MediaIdType.TVRAGE, info.getTvRageId().get()); } if (info.getTvMazeId().isPresent()) { params.put(MediaIdType.TVMAZE, info.getTvMazeId().get()); } if (info.getTvDbId().isPresent()) { params.put(MediaIdType.TVDB, info.getTvDbId().get()); } } catch (InfoProviderException e) { error("Error while converting search ID", e); } } else { debug("Unable to convert any of the provided IDs to any of these supported IDs: {}", Joiner.on(", ").join(config.getSupportedSearchIds())); } if (params.isEmpty()) { warn("Didn't find any usable IDs to add to search request"); } } params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value)); for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) { if (entry.getValue() == null) { continue; } if (!config.getSupportedSearchIds().contains(entry.getKey())) { continue; } componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", "")); } } return componentsBuilder; }  @Override NfoResult getNfo(String guid); }
Newznab extends Indexer<Xml> { protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchRequest, UriComponentsBuilder componentsBuilder) { if (!searchRequest.getIdentifiers().isEmpty()) { Map<MediaIdType, String> params = new HashMap<>(); boolean idConversionNeeded = isIdConversionNeeded(searchRequest); if (idConversionNeeded) { boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds())); if (canConvertAnyId) { try { MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers()); if (info.getImdbId().isPresent()) { if (searchRequest.getSearchType() == SearchType.MOVIE && config.getSupportedSearchIds().contains(MediaIdType.IMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } if (searchRequest.getSearchType() == SearchType.TVSEARCH && config.getSupportedSearchIds().contains(MediaIdType.TVIMDB)) { params.put(MediaIdType.IMDB, info.getImdbId().get().replace("tt", "")); } } if (info.getTmdbId().isPresent()) { params.put(MediaIdType.TMDB, info.getTmdbId().get()); } if (info.getTvRageId().isPresent()) { params.put(MediaIdType.TVRAGE, info.getTvRageId().get()); } if (info.getTvMazeId().isPresent()) { params.put(MediaIdType.TVMAZE, info.getTvMazeId().get()); } if (info.getTvDbId().isPresent()) { params.put(MediaIdType.TVDB, info.getTvDbId().get()); } } catch (InfoProviderException e) { error("Error while converting search ID", e); } } else { debug("Unable to convert any of the provided IDs to any of these supported IDs: {}", Joiner.on(", ").join(config.getSupportedSearchIds())); } if (params.isEmpty()) { warn("Didn't find any usable IDs to add to search request"); } } params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value)); for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) { if (entry.getValue() == null) { continue; } if (!config.getSupportedSearchIds().contains(entry.getKey())) { continue; } componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", "")); } } return componentsBuilder; }  @Override NfoResult getNfo(String guid);  }