@Test public void shouldCreateSearchResultItem() throws Exception { NewznabXmlItem rssItem = buildBasicRssItem(); rssItem.getNewznabAttributes().add(new NewznabAttribute("password", "0")); rssItem.getNewznabAttributes().add(new NewznabAttribute("group", "group")); rssItem.getNewznabAttributes().add(new NewznabAttribute("poster", "poster")); rssItem.getNewznabAttributes().add(new NewznabAttribute("files", "10")); rssItem.getNewznabAttributes().add(new NewznabAttribute("grabs", "20")); rssItem.getNewznabAttributes().add(new NewznabAttribute("comments", "30")); rssItem.getNewznabAttributes().add(new NewznabAttribute("usenetdate", new JaxbPubdateAdapter().marshal(Instant.ofEpochSecond(6666666)))); rssItem.getNewznabAttributes().add(new NewznabAttribute("category", "5000")); rssItem.getNewznabAttributes().add(new NewznabAttribute("category", "5050")); SearchResultItem item = testee.createSearchResultItem(rssItem); assertThat(item.getLink(), is("http: assertThat(item.getIndexerGuid(), is("123")); assertThat(item.getSize(), is(456L)); assertThat(item.getDescription(), is("description")); assertThat(item.getPubDate(), is(Instant.ofEpochSecond(5555555))); assertThat(item.getCommentsLink(), is("http: assertThat(item.getDetails(), is("http: assertThat(item.isAgePrecise(), is(true)); assertThat(item.getUsenetDate().get(), is(Instant.ofEpochSecond(6666666))); assertThat(item.getDownloadType(), is(DownloadType.NZB)); assertThat(item.isPassworded(), is(false)); assertThat(item.getGroup().get(), is("group")); assertThat(item.getPoster().get(), is("poster")); assertThat(item.getFiles(), is(10)); assertThat(item.getGrabs(), is(20)); assertThat(item.getCommentsCount(), is(30)); verify(categoryProviderMock, times(1)).fromResultNewznabCategories(Arrays.asList(5000, 5050)); rssItem.setRssGuid(new NewznabXmlGuid("123", false)); rssItem.getNewznabAttributes().clear(); rssItem.getNewznabAttributes().add(new NewznabAttribute("password", "1")); rssItem.getNewznabAttributes().add(new NewznabAttribute("nfo", "1")); item = testee.createSearchResultItem(rssItem); assertThat(item.getIndexerGuid(), is("123")); assertThat(item.isPassworded(), is(true)); assertThat(item.getHasNfo(), is(HasNfo.YES)); }
protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { SearchResultItem searchResultItem = new SearchResultItem(); String link = getEnclosureUrl(item); searchResultItem.setLink(link); if (item.getRssGuid().isPermaLink()) { searchResultItem.setDetails(item.getRssGuid().getGuid()); Matcher matcher = GUID_PATTERN.matcher(item.getRssGuid().getGuid()); if (matcher.matches()) { searchResultItem.setIndexerGuid(matcher.group(2)); } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } if (!Strings.isNullOrEmpty(item.getComments()) && Strings.isNullOrEmpty(searchResultItem.getDetails())) { searchResultItem.setDetails(item.getComments().replace("#comments", "")); } searchResultItem.setFirstFound(Instant.now()); searchResultItem.setIndexer(this); searchResultItem.setTitle(cleanUpTitle(item.getTitle())); searchResultItem.setSize(item.getEnclosure().getLength()); searchResultItem.setPubDate(item.getPubDate()); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); searchResultItem.setAgePrecise(true); searchResultItem.setDescription(item.getDescription()); searchResultItem.setDownloadType(DownloadType.NZB); searchResultItem.setCommentsLink(item.getComments()); searchResultItem.setOriginalCategory(item.getCategory()); parseAttributes(item, searchResultItem); return searchResultItem; }
Newznab extends Indexer<Xml> { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { SearchResultItem searchResultItem = new SearchResultItem(); String link = getEnclosureUrl(item); searchResultItem.setLink(link); if (item.getRssGuid().isPermaLink()) { searchResultItem.setDetails(item.getRssGuid().getGuid()); Matcher matcher = GUID_PATTERN.matcher(item.getRssGuid().getGuid()); if (matcher.matches()) { searchResultItem.setIndexerGuid(matcher.group(2)); } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } if (!Strings.isNullOrEmpty(item.getComments()) && Strings.isNullOrEmpty(searchResultItem.getDetails())) { searchResultItem.setDetails(item.getComments().replace("#comments", "")); } searchResultItem.setFirstFound(Instant.now()); searchResultItem.setIndexer(this); searchResultItem.setTitle(cleanUpTitle(item.getTitle())); searchResultItem.setSize(item.getEnclosure().getLength()); searchResultItem.setPubDate(item.getPubDate()); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); searchResultItem.setAgePrecise(true); searchResultItem.setDescription(item.getDescription()); searchResultItem.setDownloadType(DownloadType.NZB); searchResultItem.setCommentsLink(item.getComments()); searchResultItem.setOriginalCategory(item.getCategory()); parseAttributes(item, searchResultItem); return searchResultItem; } }
Newznab extends Indexer<Xml> { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { SearchResultItem searchResultItem = new SearchResultItem(); String link = getEnclosureUrl(item); searchResultItem.setLink(link); if (item.getRssGuid().isPermaLink()) { searchResultItem.setDetails(item.getRssGuid().getGuid()); Matcher matcher = GUID_PATTERN.matcher(item.getRssGuid().getGuid()); if (matcher.matches()) { searchResultItem.setIndexerGuid(matcher.group(2)); } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } if (!Strings.isNullOrEmpty(item.getComments()) && Strings.isNullOrEmpty(searchResultItem.getDetails())) { searchResultItem.setDetails(item.getComments().replace("#comments", "")); } searchResultItem.setFirstFound(Instant.now()); searchResultItem.setIndexer(this); searchResultItem.setTitle(cleanUpTitle(item.getTitle())); searchResultItem.setSize(item.getEnclosure().getLength()); searchResultItem.setPubDate(item.getPubDate()); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); searchResultItem.setAgePrecise(true); searchResultItem.setDescription(item.getDescription()); searchResultItem.setDownloadType(DownloadType.NZB); searchResultItem.setCommentsLink(item.getComments()); searchResultItem.setOriginalCategory(item.getCategory()); parseAttributes(item, searchResultItem); return searchResultItem; }  }
Newznab extends Indexer<Xml> { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { SearchResultItem searchResultItem = new SearchResultItem(); String link = getEnclosureUrl(item); searchResultItem.setLink(link); if (item.getRssGuid().isPermaLink()) { searchResultItem.setDetails(item.getRssGuid().getGuid()); Matcher matcher = GUID_PATTERN.matcher(item.getRssGuid().getGuid()); if (matcher.matches()) { searchResultItem.setIndexerGuid(matcher.group(2)); } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } if (!Strings.isNullOrEmpty(item.getComments()) && Strings.isNullOrEmpty(searchResultItem.getDetails())) { searchResultItem.setDetails(item.getComments().replace("#comments", "")); } searchResultItem.setFirstFound(Instant.now()); searchResultItem.setIndexer(this); searchResultItem.setTitle(cleanUpTitle(item.getTitle())); searchResultItem.setSize(item.getEnclosure().getLength()); searchResultItem.setPubDate(item.getPubDate()); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); searchResultItem.setAgePrecise(true); searchResultItem.setDescription(item.getDescription()); searchResultItem.setDownloadType(DownloadType.NZB); searchResultItem.setCommentsLink(item.getComments()); searchResultItem.setOriginalCategory(item.getCategory()); parseAttributes(item, searchResultItem); return searchResultItem; }  @Override NfoResult getNfo(String guid); }
Newznab extends Indexer<Xml> { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { SearchResultItem searchResultItem = new SearchResultItem(); String link = getEnclosureUrl(item); searchResultItem.setLink(link); if (item.getRssGuid().isPermaLink()) { searchResultItem.setDetails(item.getRssGuid().getGuid()); Matcher matcher = GUID_PATTERN.matcher(item.getRssGuid().getGuid()); if (matcher.matches()) { searchResultItem.setIndexerGuid(matcher.group(2)); } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } } else { searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); } if (!Strings.isNullOrEmpty(item.getComments()) && Strings.isNullOrEmpty(searchResultItem.getDetails())) { searchResultItem.setDetails(item.getComments().replace("#comments", "")); } searchResultItem.setFirstFound(Instant.now()); searchResultItem.setIndexer(this); searchResultItem.setTitle(cleanUpTitle(item.getTitle())); searchResultItem.setSize(item.getEnclosure().getLength()); searchResultItem.setPubDate(item.getPubDate()); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); searchResultItem.setAgePrecise(true); searchResultItem.setDescription(item.getDescription()); searchResultItem.setDownloadType(DownloadType.NZB); searchResultItem.setCommentsLink(item.getComments()); searchResultItem.setOriginalCategory(item.getCategory()); parseAttributes(item, searchResultItem); return searchResultItem; }  @Override NfoResult getNfo(String guid);  }