Skip to content

Commit

Permalink
Improve nzbking result filter
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Aug 17, 2024
1 parent e5e0c7e commit 21fee20
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/nzbhydra/indexers/NzbKing.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class NzbKing extends Indexer<String> {

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("(?<size>[0-9]+(\\.[0-9]+)?)(?<unit>(GB|MB|KB|B))", Pattern.CASE_INSENSITIVE);
private static final Pattern NFO_PATTERN = Pattern.compile("<pre>(?<nfo>.*)<\\/pre>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

Expand Down Expand Up @@ -106,7 +106,7 @@ protected List<SearchResultItem> 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;
Expand Down
9 changes: 6 additions & 3 deletions core/src/test/java/org/nzbhydra/indexers/NzbKingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SearchResultItem> 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<SearchResultItem> 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);
Expand Down
62 changes: 31 additions & 31 deletions core/src/test/resources/org/nzbhydra/mapping/nzbKing.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!-- saved from url=(0056)https://www.nzbking.com/search?q=Furiosa&ft=&gr=&po=&so= -->
<!-- saved from url=(0056)https://www.nzbking.com/search?q=Rabiata&ft=&gr=&po=&so= -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script async="" src="./NZBKing - Furiosa_files/js"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-30514420-1', { 'anonymize_ip': true });</script>
<script async="" src="./NZBKing - Rabiata_files/js"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-30514420-1', { 'anonymize_ip': true });</script>



Expand All @@ -13,7 +13,7 @@
<meta name="robots" content="index,follow">
<meta name="description" content="NZBKing Usenet Indexer - Search Usenet Binaries">
<meta name="keywords" content="usenet, search engine, nzb, binary, binaries, binsearch, files, indexing, indexer, service, newsgroups, nfo, yEnc, best, retention, poster, alt.binaries, picture, audio, video, mkv, avi, mp3">
<link type="text/css" rel="stylesheet" href="./NZBKing - Furiosa_files/styles8.css">
<link type="text/css" rel="stylesheet" href="./NZBKing - Rabiata_files/styles8.css">
<link rel="shortcut icon" href="https://www.nzbking.com/static/favicon.ico" type="image/x-icon">

<style>.pb-sidebar-frame-container{position:fixed;top:0;background-color:rgba(0,0,0,0);width:380px;height:100%;right:-380px;transition:right .5s;transition-timing-function:ease;z-index:2147483647}.pb-sidebar-frame-container>iframe{width:100%;height:100%;border-width:0;border-style:initial !important;border-color:initial !important;border-image:initial !important}.pb-sidebar-frame-container.in{right:0}.pb-sidebar-frame-container.out{right:-380px}.pb-notification-frame-container{position:fixed;top:0;background-color:rgba(0,0,0,0);width:363px;height:78px;right:-370px;transition:right .5s;transition-timing-function:ease;z-index:2147483647}.pb-notification-frame-container>iframe{width:100%;height:100%;border-width:0;border-style:initial !important;border-color:initial !important;border-image:initial !important}.pb-notification-frame-container.in{right:7px}.pb-notification-frame-container.out{right:-370px}.pb-notification-frame-container.cop{right:-331px}
Expand Down Expand Up @@ -75,14 +75,14 @@ <h2>Search Usenet Binaries</h2>

<div id="Simple" style="display:none;">
<form class="search">
<input class="searchField" id="qSimple" type="text" name="q" autocomplete="off" placeholder="Search usenet..." value="Furiosa">
<input class="searchField" id="qSimple" type="text" name="q" autocomplete="off" placeholder="Search usenet..." value="Rabiata">
<input class="searchSubmit" type="submit" value="">
</form>
<p><label class="hooverline" onclick="openAdvanced(event)">Advanced search</label></p>
</div>
<div id="Advanced" style="display: block;">
<form class="search">
<input class="searchField" id="qAdvanced" type="text" name="q" autocomplete="off" placeholder="Search usenet..." value="Furiosa">
<input class="searchField" id="qAdvanced" type="text" name="q" autocomplete="off" placeholder="Search usenet..." value="Rabiata">
<input class="searchSubmit" type="submit" value="">
<div class="filter-details">
<div class="filter-details-group">
Expand Down Expand Up @@ -133,7 +133,7 @@ <h2>Search Usenet Binaries</h2>
<input type="radio" name="so" value="s" id="sortsize"><label for="sortsize">Size</label>
<input type="radio" name="so" value="m" id="sortmagic"><label for="sortmagic">Magic</label>
</div>
<div><a href="https://www.nzbking.com/search?q=Furiosa&amp;ft=&amp;gr=&amp;po=&amp;so=#" id="SearchTips">tips...</a></div>
<div><a href="https://www.nzbking.com/search?q=Rabiata&amp;ft=&amp;gr=&amp;po=&amp;so=#" id="SearchTips">tips...</a></div>
</div>
</div>
</div>
Expand Down Expand Up @@ -201,10 +201,10 @@ <h3>Search results:</h3>
<input type="submit" name="action_nzb" value="Merge NZB&#39;s⬇" disabled="">
</div>
<div class="rsslink">
<a href="https://www.nzbking.com/search?q=Furiosa&amp;ft=&amp;gr=&amp;po=&amp;so=#" id="tips">How to download...</a>
<a href="https://www.nzbking.com/search?q=Rabiata&amp;ft=&amp;gr=&amp;po=&amp;so=#" id="tips">How to download...</a>

&nbsp;&nbsp;
<a href="https://www.nzbking.com/rss/search?q=Furiosa&amp;ft=&amp;gr=&amp;po=&amp;so=">Get query as RSS feed <img src="./NZBKing - Furiosa_files/rss.png"></a>
<a href="https://www.nzbking.com/rss/search?q=Rabiata&amp;ft=&amp;gr=&amp;po=&amp;so=">Get query as RSS feed <img src="./NZBKing - Rabiata_files/rss.png"></a>

</div>
<div style="clear: both;"></div>
Expand All @@ -231,7 +231,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[001/110] "Furiosa.de.la.saga.Mad.Max.2024.2160p.WEB-DL.DDP5.1.DV.HDR.H.265-KWK.par2"
[001/110] "Rabiata.de.la.saga.Crazy.John.2024.2160p.WEB-DL.DDP5.1.DV.HDR.H.265-KWK.par2"


<br>
Expand Down Expand Up @@ -284,7 +284,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[001/109] "Furiosa.de.la.saga.Mad.Max.2024.1080p.AMZN.WEB-DL.DDP5.1.H.264-KWK.par2"
[001/109] "Rabiata.de.la.saga.Crazy.John.2024.1080p.AMZN.WEB-DL.DDP5.1.H.264-KWK.par2"


<br>
Expand Down Expand Up @@ -337,7 +337,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[03/14] - "00-ramsey_westwood-furiosa-(avaw338)-web-2024.nfo" yEnc
[03/14] - "00-ramsey_westwood-Rabiata-(avaw338)-web-2024.nfo" yEnc


<br>
Expand Down Expand Up @@ -403,7 +403,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[05/14] - "01-ramsey_westwood-furiosa_(2024_tech_mix).mp3" yEnc
[05/14] - "01-ramsey_westwood-Rabiata_(2024_tech_mix).mp3" yEnc


<br>
Expand Down Expand Up @@ -456,7 +456,7 @@ <h3>Search results:</h3>



<div class="wide-banner"><a href="https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=3edae53b" rel="noreferrer" target="_top"><img src="./NZBKing - Furiosa_files/3edae53b.gif" alt="" title="" width="728" height="90" border="0"></a><img style="border:0" src="./NZBKing - Furiosa_files/7i141aw" width="1" height="1" alt=""></div><div class="narrow-banner"><script>document.write("<iframe name='banner' src='https://usenetjunction.com/scripts/7b141aw?a_aid=bytefountain&amp;a_bid=32e5b57c&amp;w=1' framespacing='0' frameborder='no' scrolling='no' width='300' height='250' allowtransparency='true'><a href='https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=32e5b57c' rel='noreferrer' target='_top'>EN 300x250 D</a></iframe>");</script><iframe name="banner" src="./NZBKing - Furiosa_files/7b141aw.html" framespacing="0" frameborder="no" scrolling="no" width="300" height="250" allowtransparency="true"><a href='https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=32e5b57c' rel='noreferrer' target='_top'>EN 300x250 D</a></iframe><noscript><h2><a href="https://www.easynews.com/">EN 300x250 D</a></h2></noscript></div>
<div class="wide-banner"><a href="https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=3edae53b" rel="noreferrer" target="_top"><img src="./NZBKing - Rabiata_files/3edae53b.gif" alt="" title="" width="728" height="90" border="0"></a><img style="border:0" src="./NZBKing - Rabiata_files/7i141aw" width="1" height="1" alt=""></div><div class="narrow-banner"><script>document.write("<iframe name='banner' src='https://usenetjunction.com/scripts/7b141aw?a_aid=bytefountain&amp;a_bid=32e5b57c&amp;w=1' framespacing='0' frameborder='no' scrolling='no' width='300' height='250' allowtransparency='true'><a href='https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=32e5b57c' rel='noreferrer' target='_top'>EN 300x250 D</a></iframe>");</script><iframe name="banner" src="./NZBKing - Rabiata_files/7b141aw.html" framespacing="0" frameborder="no" scrolling="no" width="300" height="250" allowtransparency="true"><a href='https://www.easynews.com/?a_aid=bytefountain&amp;a_bid=32e5b57c' rel='noreferrer' target='_top'>EN 300x250 D</a></iframe><noscript><h2><a href="https://www.easynews.com/">EN 300x250 D</a></h2></noscript></div>



Expand All @@ -474,7 +474,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[08/14] - "ramsey_westwood-furiosa-(avaw338)-web-2024-afo.vol000+01.par2" yEnc
[08/14] - "ramsey_westwood-Rabiata-(avaw338)-web-2024-afo.vol000+01.par2" yEnc


<br>
Expand Down Expand Up @@ -527,7 +527,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.REPACK.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.REPACK.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -585,7 +585,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.REPACK.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.REPACK.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -643,7 +643,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -701,7 +701,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -759,7 +759,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.WEBRip.x265-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.WEBRip.x265-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -817,7 +817,7 @@ <h3>Search results:</h3>
<div class="search-subject">


"Furiosa.A.Mad.Max.Saga.2024.1080p.WEB-DL.EAC3.DDP5.1.Atmos.H264.UK.NL.Sub_dut.srt" yEnc
"Rabiata.A.Crazy.John.Saga.2024.1080p.WEB-DL.EAC3.DDP5.1.Atmos.H264.UK.NL.Sub_dut.srt" yEnc


<br>
Expand Down Expand Up @@ -875,7 +875,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.WEBRip.x265-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.WEBRip.x265-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -933,7 +933,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -991,7 +991,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-NLsubs.mkv"


<br>
Expand Down Expand Up @@ -1109,7 +1109,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-Eng.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-GP-M-Eng.mkv"


<br>
Expand Down Expand Up @@ -1283,7 +1283,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-Eng.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.WEB-DL.DDP5.1.Atmos.H.264-GP-M-Eng.mkv"


<br>
Expand Down Expand Up @@ -1577,7 +1577,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[02/30] - "00-tom_holkenborg-furiosa_a_mad_max_saga_(original_motion_picture_soundtrack)-ost-web-2024.m3u" yEnc
[02/30] - "00-tom_holkenborg-Rabiata_a_mad_max_saga_(original_motion_picture_soundtrack)-ost-web-2024.m3u" yEnc


<br>
Expand Down Expand Up @@ -1641,7 +1641,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.HDTS.x264-GP-M-Eng.mp4"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.HDTS.x264-GP-M-Eng.mp4"


<br>
Expand Down Expand Up @@ -1761,7 +1761,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.1080p.Cam.X264-GP-M-Eng.mp4"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.1080p.Cam.X264-GP-M-Eng.mp4"


<br>
Expand Down Expand Up @@ -1819,7 +1819,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[1/10] "Furiosa.A.Mad.Max.Saga.2024.TS.AC3.MD.1080p.x264-GP-M.mkv"
[1/10] "Rabiata.A.Crazy.John.Saga.2024.TS.AC3.MD.1080p.x264-GP-M.mkv"


<br>
Expand Down Expand Up @@ -2633,7 +2633,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[3/10] "Furiosa-Starman (2016) [16B-44.1kHz]-SoPriceless.vol000+01.par2"
[3/10] "Rabiata-Starman (2016) [16B-44.1kHz]-SoPriceless.vol000+01.par2"


<br>
Expand Down Expand Up @@ -2750,7 +2750,7 @@ <h3>Search results:</h3>
<div class="search-subject">


[04/15] - "01-sobek-cuarantena_furiosa_(original_mix).mp3" yEnc
[04/15] - "01-sobek-cuarantena_Rabiata_(original_mix).mp3" yEnc


<br>
Expand Down

0 comments on commit 21fee20

Please sign in to comment.