Skip to content

Commit

Permalink
Don't send IMDB on tv search if not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Nov 13, 2024
1 parent d7be67a commit a4905d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions core/src/main/java/org/nzbhydra/indexers/Newznab.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchR
Map<MediaIdType, String> params = new HashMap<>();
boolean idConversionNeeded = isIdConversionNeeded(searchRequest);
if (idConversionNeeded) {
debug("Will try to convert IDs if possible");
boolean canConvertAnyId = infoProvider.canConvertAny(searchRequest.getIdentifiers().keySet(), new HashSet<>(config.getSupportedSearchIds()));
if (canConvertAnyId) {
debug("Can convert any of provided IDs {} to at least one of supported IDs {}", searchRequest.getIdentifiers().keySet(), config.getSupportedSearchIds());
try {
MediaInfo info = infoProvider.convert(searchRequest.getIdentifiers());

Expand All @@ -352,6 +354,7 @@ protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchR
if (info.getTvDbId().isPresent()) {
params.put(MediaIdType.TVDB, info.getTvDbId().get());
}
debug("Available search IDs: {}", params);
} catch (InfoProviderException e) {
error("Error while converting search ID", e);
}
Expand All @@ -366,6 +369,10 @@ protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchR

//Don't overwrite IDs provided by the calling instance, only add missing ones
params.forEach((key, value) -> searchRequest.getIdentifiers().putIfAbsent(key, value));
if (searchRequest.getSearchType() == SearchType.TVSEARCH) {
//IMDB is not the same as TVIMDB
searchRequest.getIdentifiers().remove(MediaIdType.IMDB);
}

for (Map.Entry<MediaIdType, String> entry : searchRequest.getIdentifiers().entrySet()) {
//We just add all IDs that we have (if the indexer supports them). Some indexers will find results under one ID but not the other
Expand All @@ -375,6 +382,7 @@ protected UriComponentsBuilder extendQueryUrlWithSearchIds(SearchRequest searchR
if (!config.getSupportedSearchIds().contains(entry.getKey())) {
continue;
}
debug("Using media type ID {}={}", entry.getKey(), entry.getValue());
componentsBuilder.queryParam(idTypeToParamValueMap.get(entry.getKey()), entry.getValue().replace("tt", ""));
}

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
changes:
- type: "fix"
text: "The status of downloads was not properly updated for sabnzbd downloads. Previously unmapped downloads will keep their wrong status in the history because it would be a pain to retroactively update them. See #968"
- type: "fix"
text: "Do not use IMDB IDs for indexers that don't support them. This would happen when using the TV search function in the ID and selecting a result from the autocomplete."
final: true
- version: "v7.10.0"
date: "2024-11-12"
Expand Down
2 changes: 1 addition & 1 deletion tests/system/src/test/java/org/nzbhydra/MediaInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void shouldAutocompleteMovie() throws Exception {
});
Assertions.assertThat(checkCapsResponses).isNotEmpty();
MediaInfoTO mediaInfoTO = checkCapsResponses.get(0);
Assertions.assertThat(mediaInfoTO.getImdbId()).isEqualTo("98");
Assertions.assertThat(mediaInfoTO.getTmdbId()).isEqualTo("98");

}

Expand Down

0 comments on commit a4905d8

Please sign in to comment.