@Test public void shouldParseRows() throws Exception { Instant now = Instant.now(); String enclosureUrl = "https: String link = "https: NewznabXmlRoot root = RssBuilder.builder().items( Arrays.asList( RssItemBuilder .builder("Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL") .link(link) .description("<![CDATA[\n" + "<p><font color=\"gray\">alt.binaries.hdtv.x264</font><br /> <b>1.01 GB</b><br /> 7 hours<br /> <font color=\"#3DA233\">31 files (1405 parts)</font> <font color=\"gray\">by s@nd.p (SP)</font><br /> <font color=\"#E2A910\"> 1 NFO | 9 PAR2 | 1 NZB | 19 ARCHIVE</font> - <a href=\"http: "]]>") .category("alt.binaries.hdtv.x264") .pubDate(now) .rssGuid(new NewznabXmlGuid(link, true)) .enclosure(new NewznabXmlEnclosure(enclosureUrl, 1089197181L, "application/x-nzb")) .build())).build(); List<SearchResultItem> items = testee.getSearchResultItems(root, new SearchRequest()); assertThat(items.size(), is(1)); SearchResultItem item = items.get(0); assertThat(item.getTitle(), is("Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL")); assertThat(item.getGroup().get(), is("alt.binaries.hdtv.x264")); assertThat(item.getPubDate(), is(now)); assertThat(item.isAgePrecise(), is(true)); assertThat(item.getSize(), is(1089197181L)); assertThat(item.getIndexerGuid(), is("164950363")); assertThat(item.getDownloadType(), is(DownloadType.NZB)); assertThat(item.getHasNfo(), is(HasNfo.NO)); }
@Override protected List<SearchResultItem> getSearchResultItems(NewznabXmlRoot rssRoot, SearchRequest searchRequest) { if (rssRoot.getRssChannel().getItems() == null || rssRoot.getRssChannel().getItems().isEmpty()) { debug("No results found"); return Collections.emptyList(); } List<SearchResultItem> items = new ArrayList<>(); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { SearchResultItem item = new SearchResultItem(); item.setPubDate(rssItem.getPubDate()); String nzbIndexLink = rssItem.getLink(); item.setTitle(rssItem.getTitle()); item.setAgePrecise(true); if (rssItem.getCategory() != null) { item.setGroup(rssItem.getCategory().replace("a.b", "alt.binaries")); } item.setLink(rssItem.getEnclosure().getUrl()); item.setSize(rssItem.getEnclosure().getLength()); Matcher matcher = GUID_PATTERN.matcher(nzbIndexLink); boolean found = matcher.find(); if (!found) { logger.error("Unable to parse '{}' result for link. Skipping it", nzbIndexLink); continue; } item.setIndexerGuid(matcher.group(1)); item.setCategory(categoryProvider.getNotAvailable()); item.setOriginalCategory("N/A"); item.setIndexerScore(config.getScore()); if (item.getDescription() != null) { item.setHasNfo(rssItem.getDescription().contains("1 NFO") ? HasNfo.YES : HasNfo.NO); } else { item.setHasNfo(HasNfo.NO); } item.setIndexer(this); item.setDownloadType(DownloadType.NZB); items.add(item); } return items; }
NzbIndex extends Indexer<NewznabXmlRoot> { @Override protected List<SearchResultItem> getSearchResultItems(NewznabXmlRoot rssRoot, SearchRequest searchRequest) { if (rssRoot.getRssChannel().getItems() == null || rssRoot.getRssChannel().getItems().isEmpty()) { debug("No results found"); return Collections.emptyList(); } List<SearchResultItem> items = new ArrayList<>(); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { SearchResultItem item = new SearchResultItem(); item.setPubDate(rssItem.getPubDate()); String nzbIndexLink = rssItem.getLink(); item.setTitle(rssItem.getTitle()); item.setAgePrecise(true); if (rssItem.getCategory() != null) { item.setGroup(rssItem.getCategory().replace("a.b", "alt.binaries")); } item.setLink(rssItem.getEnclosure().getUrl()); item.setSize(rssItem.getEnclosure().getLength()); Matcher matcher = GUID_PATTERN.matcher(nzbIndexLink); boolean found = matcher.find(); if (!found) { logger.error("Unable to parse '{}' result for link. Skipping it", nzbIndexLink); continue; } item.setIndexerGuid(matcher.group(1)); item.setCategory(categoryProvider.getNotAvailable()); item.setOriginalCategory("N/A"); item.setIndexerScore(config.getScore()); if (item.getDescription() != null) { item.setHasNfo(rssItem.getDescription().contains("1 NFO") ? HasNfo.YES : HasNfo.NO); } else { item.setHasNfo(HasNfo.NO); } item.setIndexer(this); item.setDownloadType(DownloadType.NZB); items.add(item); } return items; } }
NzbIndex extends Indexer<NewznabXmlRoot> { @Override protected List<SearchResultItem> getSearchResultItems(NewznabXmlRoot rssRoot, SearchRequest searchRequest) { if (rssRoot.getRssChannel().getItems() == null || rssRoot.getRssChannel().getItems().isEmpty()) { debug("No results found"); return Collections.emptyList(); } List<SearchResultItem> items = new ArrayList<>(); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { SearchResultItem item = new SearchResultItem(); item.setPubDate(rssItem.getPubDate()); String nzbIndexLink = rssItem.getLink(); item.setTitle(rssItem.getTitle()); item.setAgePrecise(true); if (rssItem.getCategory() != null) { item.setGroup(rssItem.getCategory().replace("a.b", "alt.binaries")); } item.setLink(rssItem.getEnclosure().getUrl()); item.setSize(rssItem.getEnclosure().getLength()); Matcher matcher = GUID_PATTERN.matcher(nzbIndexLink); boolean found = matcher.find(); if (!found) { logger.error("Unable to parse '{}' result for link. Skipping it", nzbIndexLink); continue; } item.setIndexerGuid(matcher.group(1)); item.setCategory(categoryProvider.getNotAvailable()); item.setOriginalCategory("N/A"); item.setIndexerScore(config.getScore()); if (item.getDescription() != null) { item.setHasNfo(rssItem.getDescription().contains("1 NFO") ? HasNfo.YES : HasNfo.NO); } else { item.setHasNfo(HasNfo.NO); } item.setIndexer(this); item.setDownloadType(DownloadType.NZB); items.add(item); } return items; }  }
NzbIndex extends Indexer<NewznabXmlRoot> { @Override protected List<SearchResultItem> getSearchResultItems(NewznabXmlRoot rssRoot, SearchRequest searchRequest) { if (rssRoot.getRssChannel().getItems() == null || rssRoot.getRssChannel().getItems().isEmpty()) { debug("No results found"); return Collections.emptyList(); } List<SearchResultItem> items = new ArrayList<>(); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { SearchResultItem item = new SearchResultItem(); item.setPubDate(rssItem.getPubDate()); String nzbIndexLink = rssItem.getLink(); item.setTitle(rssItem.getTitle()); item.setAgePrecise(true); if (rssItem.getCategory() != null) { item.setGroup(rssItem.getCategory().replace("a.b", "alt.binaries")); } item.setLink(rssItem.getEnclosure().getUrl()); item.setSize(rssItem.getEnclosure().getLength()); Matcher matcher = GUID_PATTERN.matcher(nzbIndexLink); boolean found = matcher.find(); if (!found) { logger.error("Unable to parse '{}' result for link. Skipping it", nzbIndexLink); continue; } item.setIndexerGuid(matcher.group(1)); item.setCategory(categoryProvider.getNotAvailable()); item.setOriginalCategory("N/A"); item.setIndexerScore(config.getScore()); if (item.getDescription() != null) { item.setHasNfo(rssItem.getDescription().contains("1 NFO") ? HasNfo.YES : HasNfo.NO); } else { item.setHasNfo(HasNfo.NO); } item.setIndexer(this); item.setDownloadType(DownloadType.NZB); items.add(item); } return items; }  @Override NfoResult getNfo(String guid); }
NzbIndex extends Indexer<NewznabXmlRoot> { @Override protected List<SearchResultItem> getSearchResultItems(NewznabXmlRoot rssRoot, SearchRequest searchRequest) { if (rssRoot.getRssChannel().getItems() == null || rssRoot.getRssChannel().getItems().isEmpty()) { debug("No results found"); return Collections.emptyList(); } List<SearchResultItem> items = new ArrayList<>(); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { SearchResultItem item = new SearchResultItem(); item.setPubDate(rssItem.getPubDate()); String nzbIndexLink = rssItem.getLink(); item.setTitle(rssItem.getTitle()); item.setAgePrecise(true); if (rssItem.getCategory() != null) { item.setGroup(rssItem.getCategory().replace("a.b", "alt.binaries")); } item.setLink(rssItem.getEnclosure().getUrl()); item.setSize(rssItem.getEnclosure().getLength()); Matcher matcher = GUID_PATTERN.matcher(nzbIndexLink); boolean found = matcher.find(); if (!found) { logger.error("Unable to parse '{}' result for link. Skipping it", nzbIndexLink); continue; } item.setIndexerGuid(matcher.group(1)); item.setCategory(categoryProvider.getNotAvailable()); item.setOriginalCategory("N/A"); item.setIndexerScore(config.getScore()); if (item.getDescription() != null) { item.setHasNfo(rssItem.getDescription().contains("1 NFO") ? HasNfo.YES : HasNfo.NO); } else { item.setHasNfo(HasNfo.NO); } item.setIndexer(this); item.setDownloadType(DownloadType.NZB); items.add(item); } return items; }  @Override NfoResult getNfo(String guid);  }