From 21fee209b0556297a65e934962d2fb62443b3cb8 Mon Sep 17 00:00:00 2001 From: TheOtherP Date: Sat, 17 Aug 2024 09:13:23 +0200 Subject: [PATCH] Improve nzbking result filter --- .../java/org/nzbhydra/indexers/NzbKing.java | 4 +- .../org/nzbhydra/indexers/NzbKingTest.java | 9 ++- .../org/nzbhydra/mapping/nzbKing.html | 62 +++++++++---------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/org/nzbhydra/indexers/NzbKing.java b/core/src/main/java/org/nzbhydra/indexers/NzbKing.java index 2b3b584ae..2e6e52328 100644 --- a/core/src/main/java/org/nzbhydra/indexers/NzbKing.java +++ b/core/src/main/java/org/nzbhydra/indexers/NzbKing.java @@ -54,7 +54,7 @@ public class NzbKing extends Indexer { private static final Logger logger = LoggerFactory.getLogger(NzbKing.class); - private static final Pattern TITLE_PATTERN = Pattern.compile("\"?(.*)\\.(rar|nfo|mkv|mp3|mobi|avi|mp4|m3u|epub|txt|pdf|par2|001|nzb|url|jpg|zip|flac|m4a|m4b|sfv|7z|md5|r[0-9]{2})\"?", Pattern.CASE_INSENSITIVE); //Note the " (quotation marks) + private static final Pattern TITLE_PATTERN = Pattern.compile("\"(.*)\\.(rar|nfo|mkv|mp3|mobi|avi|mp4|m3u|epub|txt|pdf|par2|001|nzb|url|jpg|zip|flac|m4a|m4b|sfv|7z|md5|r[0-9]{2})\"?", Pattern.CASE_INSENSITIVE); //Note the " (quotation marks) private static final Pattern SIZE_PATTERN = Pattern.compile("(?[0-9]+(\\.[0-9]+)?)(?(GB|MB|KB|B))", Pattern.CASE_INSENSITIVE); private static final Pattern NFO_PATTERN = Pattern.compile("
(?.*)<\\/pre>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
 
@@ -106,7 +106,7 @@ protected List getSearchResultItems(String searchRequestRespon
             }
             isFirstGroup = false;
         }
-        items.removeIf(item -> searchRequest.getInternalData().getQueryWords().stream().noneMatch(queryWord -> item.getTitle().contains(queryWord)));
+        items.removeIf(item -> !searchRequest.getInternalData().getQueryWords().stream().allMatch(queryWord -> item.getTitle().toLowerCase().contains(queryWord.toLowerCase())));
         debug("Finished parsing {} of {} rows", items.size(), allRows.size());
 
         return items;
diff --git a/core/src/test/java/org/nzbhydra/indexers/NzbKingTest.java b/core/src/test/java/org/nzbhydra/indexers/NzbKingTest.java
index e76e50fbc..42cd83869 100644
--- a/core/src/test/java/org/nzbhydra/indexers/NzbKingTest.java
+++ b/core/src/test/java/org/nzbhydra/indexers/NzbKingTest.java
@@ -76,10 +76,13 @@ public void setUp() throws Exception {
     @Test
     void shouldParseResultsCorrectly() throws Exception {
         String html = Resources.toString(Resources.getResource(NzbKingTest.class, "/org/nzbhydra/mapping/nzbKing.html"), Charsets.UTF_8);
-        List searchResultItems = testee.getSearchResultItems(html, new SearchRequest());
-        assertThat(searchResultItems.size()).isEqualTo(48);
+        SearchRequest searchRequest = new SearchRequest();
+        searchRequest.setQuery("rabiata");
+        searchRequest.getInternalData().setQueryWords(List.of("rabiata"));
+        List searchResultItems = testee.getSearchResultItems(html, searchRequest);
+        assertThat(searchResultItems.size()).isEqualTo(21);
         SearchResultItem item = searchResultItems.get(0);
-        assertThat(item.getTitle()).isEqualTo("Furiosa.de.la.saga.Mad.Max.2024.2160p.WEB-DL.DDP5.1.DV.HDR.H.265-KWK");
+        assertThat(item.getTitle()).isEqualTo("Rabiata.de.la.saga.Crazy.John.2024.2160p.WEB-DL.DDP5.1.DV.HDR.H.265-KWK");
         assertThat(item.getLink()).isEqualTo("https://www.nzbking.com/nzb:669923f04e4d6b10f89f50fb");
         assertThat(item.getDetails()).isEqualTo("https://www.nzbking.com/details:669923f04e4d6b10f89f50fb");
         assertThat(item.getSize()).isEqualTo(30064771072L);
diff --git a/core/src/test/resources/org/nzbhydra/mapping/nzbKing.html b/core/src/test/resources/org/nzbhydra/mapping/nzbKing.html
index 524bc3305..79ca9413a 100644
--- a/core/src/test/resources/org/nzbhydra/mapping/nzbKing.html
+++ b/core/src/test/resources/org/nzbhydra/mapping/nzbKing.html
@@ -1,7 +1,7 @@
 
-
+
  
-	
+	
 
 
 	
@@ -13,7 +13,7 @@
 	 
 	 
 	 
-	 
+