protected List<Integer> tryAndGetCategoryAsNumber(NewznabXmlItem item) { Set<Integer> foundCategories = new HashSet<>(); if (item.getCategory() != null) { try { foundCategories.add(Integer.parseInt(item.getCategory())); } catch (NumberFormatException e) { //NOP } } foundCategories.addAll(item.getNewznabAttributes().stream().filter(x -> x.getName().equals("category")).map(x -> Integer.valueOf(x.getValue())).collect(Collectors.toList())); foundCategories.addAll(item.getTorznabAttributes().stream().filter(x -> x.getName().equals("category")).map(x -> Integer.valueOf(x.getValue())).collect(Collectors.toList())); return new ArrayList<>(foundCategories); }
protected void parseAttributes(NewznabXmlItem item, SearchResultItem searchResultItem) { Map<String, String> attributes = item.getNewznabAttributes().stream().collect(Collectors.toMap(NewznabAttribute::getName, NewznabAttribute::getValue, (a, b) -> b)); List<Integer> newznabCategories = item.getNewznabAttributes().stream().filter(x -> x.getName().equals("category") && !"None".equals(x.getValue()) && !Strings.isNullOrEmpty(x.getValue())).map(newznabAttribute -> Integer.parseInt(newznabAttribute.getValue())).collect(Collectors.toList()); searchResultItem.setAttributes(attributes);
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;