@Test public void shouldCreateSearchResultItem() throws Exception { NewznabXmlItem rssItem = buildBasicRssItem(); rssItem.setSize(456L); rssItem.getTorznabAttributes().add(new NewznabAttribute("password", "0")); rssItem.getTorznabAttributes().add(new NewznabAttribute("group", "group")); rssItem.getTorznabAttributes().add(new NewznabAttribute("poster", "poster")); rssItem.getTorznabAttributes().add(new NewznabAttribute("size", "456")); rssItem.getTorznabAttributes().add(new NewznabAttribute("files", "10")); rssItem.getTorznabAttributes().add(new NewznabAttribute("grabs", "20")); rssItem.getTorznabAttributes().add(new NewznabAttribute("comments", "30")); rssItem.getTorznabAttributes().add(new NewznabAttribute("usenetdate", new JaxbPubdateAdapter().marshal(Instant.ofEpochSecond(6666666)))); rssItem.getEnclosures().add(new NewznabXmlEnclosure("http: rssItem.setCategory("4000"); SearchResultItem item = testee.createSearchResultItem(rssItem); assertThat(item.getLink(), is("http: assertThat(item.getIndexerGuid(), is("http: assertThat(item.getSize(), is(456L)); assertThat(item.getCommentsLink(), is("http: assertThat(item.getDetails(), is("http: assertThat(item.isAgePrecise(), is(true)); assertThat(item.getGrabs(), is(20)); assertThat(item.getDownloadType(), is(DownloadType.TORRENT)); }
protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { item.getRssGuid().setPermaLink(true); SearchResultItem searchResultItem = super.createSearchResultItem(item); searchResultItem.setGrabs(item.getGrabs()); searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); for (NewznabAttribute attribute : item.getTorznabAttributes()) { searchResultItem.getAttributes().put(attribute.getName(), attribute.getValue()); switch (attribute.getName()) { case "grabs": searchResultItem.setGrabs(Integer.valueOf(attribute.getValue())); break; case "guid": searchResultItem.setIndexerGuid(attribute.getValue()); break; case "seeders": searchResultItem.setSeeders(Integer.valueOf(attribute.getValue())); break; case "peers": searchResultItem.setPeers(Integer.valueOf(attribute.getValue())); break; } } if (item.getSize() != null) { searchResultItem.setSize(item.getSize()); } else if (item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) { searchResultItem.getAttributes().put("size", String.valueOf(item.getSize())); } List<Integer> foundCategories = tryAndGetCategoryAsNumber(item); if (!foundCategories.isEmpty()) { computeCategory(searchResultItem, foundCategories); } else { searchResultItem.setCategory(categoryProvider.getNotAvailable()); } searchResultItem.setHasNfo(HasNfo.NO); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setDownloadType(DownloadType.TORRENT); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); return searchResultItem; }
Torznab extends Newznab { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { item.getRssGuid().setPermaLink(true); SearchResultItem searchResultItem = super.createSearchResultItem(item); searchResultItem.setGrabs(item.getGrabs()); searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); for (NewznabAttribute attribute : item.getTorznabAttributes()) { searchResultItem.getAttributes().put(attribute.getName(), attribute.getValue()); switch (attribute.getName()) { case "grabs": searchResultItem.setGrabs(Integer.valueOf(attribute.getValue())); break; case "guid": searchResultItem.setIndexerGuid(attribute.getValue()); break; case "seeders": searchResultItem.setSeeders(Integer.valueOf(attribute.getValue())); break; case "peers": searchResultItem.setPeers(Integer.valueOf(attribute.getValue())); break; } } if (item.getSize() != null) { searchResultItem.setSize(item.getSize()); } else if (item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) { searchResultItem.getAttributes().put("size", String.valueOf(item.getSize())); } List<Integer> foundCategories = tryAndGetCategoryAsNumber(item); if (!foundCategories.isEmpty()) { computeCategory(searchResultItem, foundCategories); } else { searchResultItem.setCategory(categoryProvider.getNotAvailable()); } searchResultItem.setHasNfo(HasNfo.NO); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setDownloadType(DownloadType.TORRENT); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); return searchResultItem; } }
Torznab extends Newznab { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { item.getRssGuid().setPermaLink(true); SearchResultItem searchResultItem = super.createSearchResultItem(item); searchResultItem.setGrabs(item.getGrabs()); searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); for (NewznabAttribute attribute : item.getTorznabAttributes()) { searchResultItem.getAttributes().put(attribute.getName(), attribute.getValue()); switch (attribute.getName()) { case "grabs": searchResultItem.setGrabs(Integer.valueOf(attribute.getValue())); break; case "guid": searchResultItem.setIndexerGuid(attribute.getValue()); break; case "seeders": searchResultItem.setSeeders(Integer.valueOf(attribute.getValue())); break; case "peers": searchResultItem.setPeers(Integer.valueOf(attribute.getValue())); break; } } if (item.getSize() != null) { searchResultItem.setSize(item.getSize()); } else if (item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) { searchResultItem.getAttributes().put("size", String.valueOf(item.getSize())); } List<Integer> foundCategories = tryAndGetCategoryAsNumber(item); if (!foundCategories.isEmpty()) { computeCategory(searchResultItem, foundCategories); } else { searchResultItem.setCategory(categoryProvider.getNotAvailable()); } searchResultItem.setHasNfo(HasNfo.NO); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setDownloadType(DownloadType.TORRENT); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); return searchResultItem; }  }
Torznab extends Newznab { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { item.getRssGuid().setPermaLink(true); SearchResultItem searchResultItem = super.createSearchResultItem(item); searchResultItem.setGrabs(item.getGrabs()); searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); for (NewznabAttribute attribute : item.getTorznabAttributes()) { searchResultItem.getAttributes().put(attribute.getName(), attribute.getValue()); switch (attribute.getName()) { case "grabs": searchResultItem.setGrabs(Integer.valueOf(attribute.getValue())); break; case "guid": searchResultItem.setIndexerGuid(attribute.getValue()); break; case "seeders": searchResultItem.setSeeders(Integer.valueOf(attribute.getValue())); break; case "peers": searchResultItem.setPeers(Integer.valueOf(attribute.getValue())); break; } } if (item.getSize() != null) { searchResultItem.setSize(item.getSize()); } else if (item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) { searchResultItem.getAttributes().put("size", String.valueOf(item.getSize())); } List<Integer> foundCategories = tryAndGetCategoryAsNumber(item); if (!foundCategories.isEmpty()) { computeCategory(searchResultItem, foundCategories); } else { searchResultItem.setCategory(categoryProvider.getNotAvailable()); } searchResultItem.setHasNfo(HasNfo.NO); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setDownloadType(DownloadType.TORRENT); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); return searchResultItem; }   }
Torznab extends Newznab { protected SearchResultItem createSearchResultItem(NewznabXmlItem item) throws NzbHydraException { item.getRssGuid().setPermaLink(true); SearchResultItem searchResultItem = super.createSearchResultItem(item); searchResultItem.setGrabs(item.getGrabs()); searchResultItem.setIndexerGuid(item.getRssGuid().getGuid()); for (NewznabAttribute attribute : item.getTorznabAttributes()) { searchResultItem.getAttributes().put(attribute.getName(), attribute.getValue()); switch (attribute.getName()) { case "grabs": searchResultItem.setGrabs(Integer.valueOf(attribute.getValue())); break; case "guid": searchResultItem.setIndexerGuid(attribute.getValue()); break; case "seeders": searchResultItem.setSeeders(Integer.valueOf(attribute.getValue())); break; case "peers": searchResultItem.setPeers(Integer.valueOf(attribute.getValue())); break; } } if (item.getSize() != null) { searchResultItem.setSize(item.getSize()); } else if (item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) { searchResultItem.getAttributes().put("size", String.valueOf(item.getSize())); } List<Integer> foundCategories = tryAndGetCategoryAsNumber(item); if (!foundCategories.isEmpty()) { computeCategory(searchResultItem, foundCategories); } else { searchResultItem.setCategory(categoryProvider.getNotAvailable()); } searchResultItem.setHasNfo(HasNfo.NO); searchResultItem.setIndexerScore(config.getScore()); searchResultItem.setDownloadType(DownloadType.TORRENT); searchResultItem.setGuid(SearchResultIdCalculator.calculateSearchResultId(searchResultItem)); return searchResultItem; }    }