use of org.nzbhydra.mapping.newznab.caps.CapsCategory in project nzbhydra2 by theotherp.
the class NewznabChecker method readAndConvertCategories.
private List<CapsCategory> readAndConvertCategories(CapsRoot capsRoot, IndexerCategoryConfig categoryConfig) {
List<CapsCategory> categories = new ArrayList<>(capsRoot.getCategories().getCategories());
List<MainCategory> configMainCategories = new ArrayList<>();
for (CapsCategory category : capsRoot.getCategories().getCategories()) {
List<SubCategory> configSubcats = new ArrayList<>();
if (category.getSubCategories() != null) {
categories.addAll(category.getSubCategories());
configSubcats = category.getSubCategories().stream().map(x -> new SubCategory(x.getId(), x.getName())).collect(Collectors.toList());
}
configMainCategories.add(new MainCategory(category.getId(), category.getName(), configSubcats));
}
categoryConfig.setCategories(configMainCategories);
return categories;
}
use of org.nzbhydra.mapping.newznab.caps.CapsCategory in project nzbhydra2 by theotherp.
the class RssCapsMappingTest method shouldGenerateCorrectXml.
@Test
public void shouldGenerateCorrectXml() throws JsonProcessingException, JAXBException {
CapsRoot caps = new CapsRoot();
List<CapsCategory> categories = new ArrayList<>();
CapsCategory capsCategory = new CapsCategory(1000, "1000");
List<CapsCategory> subCats = new ArrayList<>();
subCats.add(new CapsCategory(1010, "1010"));
capsCategory.setSubCategories(subCats);
caps.getCategories().getCategories().add(capsCategory);
StringWriter writer = new StringWriter();
StreamResult streamResult = new StreamResult(writer);
jaxb2Marshaller.marshal(caps, streamResult);
assertThat(writer.toString(), containsString("<categories>\n" + " <category id=\"1000\" name=\"1000\">\n" + " <subcat id=\"1010\" name=\"1010\"/>\n" + " </category>\n" + " </categories>"));
}
use of org.nzbhydra.mapping.newznab.caps.CapsCategory in project nzbhydra2 by theotherp.
the class NewznabChecker method setSupportedSearchTypesAndIndexerCategoryMapping.
public IndexerCategoryConfig setSupportedSearchTypesAndIndexerCategoryMapping(IndexerConfig indexerConfig, int timeout) throws IndexerAccessException {
List<IdType> supportedSearchIds = indexerConfig.getSupportedSearchIds();
List<ActionAttribute> supportedSearchTypes = new ArrayList<>();
if (supportedSearchIds.contains(IdType.TVDB) || supportedSearchIds.contains(IdType.TVRAGE) || supportedSearchIds.contains(IdType.TVMAZE) || supportedSearchIds.contains(IdType.TRAKT)) {
supportedSearchTypes.add(ActionAttribute.TVSEARCH);
}
if (supportedSearchIds.contains(IdType.IMDB) || supportedSearchIds.contains(IdType.TMDB)) {
supportedSearchTypes.add(ActionAttribute.MOVIE);
}
URI uri = getBaseUri(indexerConfig).queryParam("t", "caps").build().toUri();
CapsRoot capsRoot = indexerWebAccess.get(uri, indexerConfig);
if (capsRoot.getSearching().getAudioSearch() != null) {
supportedSearchTypes.add(ActionAttribute.AUDIO);
}
if (capsRoot.getSearching().getBookSearch() != null) {
supportedSearchTypes.add(ActionAttribute.BOOK);
}
indexerConfig.setSupportedSearchTypes(supportedSearchTypes);
IndexerCategoryConfig categoryConfig = new IndexerCategoryConfig();
List<CapsCategory> categories = readAndConvertCategories(capsRoot, categoryConfig);
setCategorySpecificMappings(categoryConfig, categories);
return categoryConfig;
}
Aggregations