Skip to content

Commit

Permalink
Try conversion from all available IDs
Browse files Browse the repository at this point in the history
Closes #964
  • Loading branch information
theotherp committed Sep 15, 2024
1 parent accc01a commit c85d22a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/nzbhydra/indexers/QueryGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public synchronized String generateQueryIfApplicable(SearchRequest searchRequest
throw new IndexerSearchAbortedException("Unable to generate query because no identifier is known");
}
try {
MediaInfo mediaInfo = infoProvider.convert(firstIdentifierEntry.get().getValue(), firstIdentifierEntry.get().getKey());
MediaInfo mediaInfo = infoProvider.convert(searchRequest.getIdentifiers());
if (mediaInfo.getTitle().isEmpty()) {
throw new IndexerSearchAbortedException("Unable to generate query because no title is known");
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public synchronized String generateQueryIfApplicable(SearchRequest searchRequest
}
}

logger.debug("{} does not support any of the supplied IDs or the requested search type. The following query was generated{} ", indexer.getName(), query);
logger.debug("{} does not support any of the supplied IDs or the requested search type. The following query was generated: {} ", indexer.getName(), query);

generatedQueries.put(searchRequest, query);
searchRequest.getInternalData().setQueryGenerated(true);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/nzbhydra/logging/LogAnonymizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public String getAnonymizedLog(String log) {
log = log.replaceAll("remember-me=(\\w)+;?", "remember-me=$1:<HIDDEN>");
log = log.replaceAll("Auth-Token=(\\w)+;?", "Auth-Token=$1:<HIDDEN>");
log = log.replaceAll("HYDRA-XSRF-TOKEN=([\\w\\-])+;?", "HYDRA-XSRF-TOKEN=$1:<HIDDEN>");
log = log.replaceAll("with username \\w+", "with username <HIDDEN>");
log = log.replaceAll("from username \\w+", "with username <HIDDEN>");

logger.debug("Removing base path from log");
log = log.replace(new File("").getAbsolutePath(), "<BASEPATH>");
Expand Down
13 changes: 9 additions & 4 deletions core/src/main/java/org/nzbhydra/mediainfo/InfoProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ public boolean canConvertAny(Set<MediaIdType> from, Set<MediaIdType> to) {
return from.stream().anyMatch(x -> canConvertMap.containsKey(x) && canConvertMap.get(x).stream().anyMatch(to::contains));
}

@Cacheable(cacheNames = "infos", sync = true)
public MediaInfo convert(Map<MediaIdType, String> identifiers) throws InfoProviderException {
for (MediaIdType idType : REAL_ID_TYPES) {
if (identifiers.containsKey(idType) && identifiers.get(idType) != null) {
return convert(identifiers.get(idType), idType);
try {
return convert(identifiers.get(idType), idType);
} catch (InfoProviderException ignored) {
//Already logged in call, we continue and hope another ID will work
}
}
}

Expand Down Expand Up @@ -156,11 +161,11 @@ public synchronized MediaInfo convert(String value, MediaIdType fromType) throws
default:
throw new IllegalArgumentException("Wrong IdType");
}
logger.debug("Conversion successful: " + info);
logger.debug("Conversion successful: {}", info);
mediaInfoMap.put(hash, info);
return info;
} catch (Exception e) {
logger.error("Error while converting " + fromType + " " + value, e);
logger.error("Error while converting {} {}", fromType, value, e);
Throwables.throwIfInstanceOf(e, InfoProviderException.class);
throw new InfoProviderException("Unexpected error while converting infos", e);
}
Expand Down Expand Up @@ -203,7 +208,7 @@ public List<MediaInfo> search(String title, MediaIdType titleType) throws InfoPr

return infos;
} catch (Exception e) {
logger.error("Error while searching for " + titleType + " " + title, e);
logger.error("Error while searching for {} {}", titleType, title, e);
Throwables.throwIfInstanceOf(e, InfoProviderException.class);
throw new InfoProviderException("Unexpected error while converting infos", e);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/nzbhydra/searching/SearchWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class SearchWeb {
public SearchResponse search(@RequestBody SearchRequestParameters parameters) {
SearchRequest searchRequest = createSearchRequest(parameters);
Stopwatch stopwatch = Stopwatch.createStarted();
logger.info("New search request: " + searchRequest);
logger.info("New search request: {}", searchRequest);
org.nzbhydra.searching.SearchResult searchResult = searcher.search(searchRequest);

SearchResponse searchResponse = searchResultProcessor.createSearchResponse(searchResult);
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/static/js/nzbhydra.js
Original file line number Diff line number Diff line change
Expand Up @@ -4434,7 +4434,7 @@ angular.module('nzbhydraApp').controller('IndexerConfigSelectionBoxInstanceContr
{
name: "SceneNZBs",
host: "https://scenenzbs.com",
info: "If you want german or spanish results make sure to add the newznab IDs in the categories config.<br>For example for german UHD movies add 2145.<br>You can find out the IDs by browsing the categories on the indexer website."
info: "If you want german or spanish (or other language specific) results make sure to add the newznab IDs in the categories config.<br>For example for german UHD movies add 2145.<br>You can find out the IDs by browsing https://scenenzbs.com/rss."
},
{
name: "spotweb.com",
Expand Down Expand Up @@ -9690,6 +9690,7 @@ function SearchService($http) {
searchRequestParameters.imdbId = metaData.imdbId;
} else if (category.indexOf("TV") > -1 || (category.indexOf("50") === 0) || mode === "tvsearch") {
searchRequestParameters.tvdbId = metaData.tvdbId;
searchRequestParameters.imdbId = metaData.imdbId;
searchRequestParameters.tvrageId = metaData.rid;
searchRequestParameters.tvmazeId = metaData.tvmazeId;
searchRequestParameters.season = season;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/static/js/nzbhydra.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/ui-src/js/config/formly-indexers.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ angular.module('nzbhydraApp').controller('IndexerConfigSelectionBoxInstanceContr
{
name: "SceneNZBs",
host: "https://scenenzbs.com",
info: "If you want german or spanish results make sure to add the newznab IDs in the categories config.<br>For example for german UHD movies add 2145.<br>You can find out the IDs by browsing the categories on the indexer website."
info: "If you want german or spanish (or other language specific) results make sure to add the newznab IDs in the categories config.<br>For example for german UHD movies add 2145.<br>You can find out the IDs by browsing https://scenenzbs.com/rss."
},
{
name: "spotweb.com",
Expand Down
1 change: 1 addition & 0 deletions core/ui-src/js/search-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function SearchService($http) {
searchRequestParameters.imdbId = metaData.imdbId;
} else if (category.indexOf("TV") > -1 || (category.indexOf("50") === 0) || mode === "tvsearch") {
searchRequestParameters.tvdbId = metaData.tvdbId;
searchRequestParameters.imdbId = metaData.imdbId;
searchRequestParameters.tvrageId = metaData.rid;
searchRequestParameters.tvmazeId = metaData.tvmazeId;
searchRequestParameters.season = season;
Expand Down

0 comments on commit c85d22a

Please sign in to comment.