Codota Logo
NewznabAttribute
Code IndexAdd Codota to your IDE (free)

How to use
NewznabAttribute
in
org.nzbhydra.mapping.newznab.xml

Best Java code snippets using org.nzbhydra.mapping.newznab.xml.NewznabAttribute (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: theotherp/nzbhydra2

public RssItemBuilder categoryNewznab(String... categories) {
  for (String s : categories) {
    newznabAttributes.add(new NewznabAttribute("category", s));
  }
  return this;
}
origin: theotherp/nzbhydra2

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);
}
origin: theotherp/nzbhydra2

public RssItemBuilder group(String group) {
  newznabAttributes.add(new NewznabAttribute("group", group));
  return this;
}
origin: theotherp/nzbhydra2

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);
origin: theotherp/nzbhydra2

public RssItemBuilder hasNfo(boolean hasNfo) {
  newznabAttributes.add(new NewznabAttribute("nfo", hasNfo ? "1" : "0"));
  return this;
}
origin: theotherp/nzbhydra2

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 && item.getTorznabAttributes().stream().noneMatch(x -> x.getName().equals("size"))) {
  searchResultItem.getAttributes().put("size", String.valueOf(item.getSize()));
origin: theotherp/nzbhydra2

public RssItemBuilder poster(String poster) {
  newznabAttributes.add(new NewznabAttribute("poster", poster));
  return this;
}
origin: theotherp/nzbhydra2

@RequestMapping(value = "/torznab/api", produces = MediaType.TEXT_XML_VALUE)
public ResponseEntity<? extends Object> torznabapi(NewznabParameters params) throws Exception {
  if (params.getT() == ActionAttribute.CAPS) {
    return new ResponseEntity<Object>(NewznabMockBuilder.getCaps(), HttpStatus.OK);
  }
  NewznabXmlRoot rssRoot = NewznabMockBuilder.generateResponse(0, 10, params.getApikey(), false, Collections.emptyList());
  Random random = new Random();
  for (NewznabXmlItem item : rssRoot.getRssChannel().getItems()) {
    item.setNewznabAttributes(new ArrayList<>());
    item.getTorznabAttributes().add(new NewznabAttribute("seeders", String.valueOf(random.nextInt(30000))));
    item.getTorznabAttributes().add(new NewznabAttribute("peers", String.valueOf(random.nextInt(30000))));
    if (random.nextInt(5) > 3) {
      item.getTorznabAttributes().add(new NewznabAttribute("grabs", String.valueOf(random.nextInt(30000))));
    }
    item.setCategory("5000");
    item.setGrabs(null);
  }
  return new ResponseEntity<Object>(rssRoot, HttpStatus.OK);
}
origin: theotherp/nzbhydra2

attributes.add(new NewznabAttribute("category", String.valueOf(newznabCategories.get(random.nextInt(newznabCategories.size())))));
attributes.add(new NewznabAttribute("size", size));
attributes.add(new NewznabAttribute("guid", guid));
attributes.add(new NewznabAttribute("poster", poster));
attributes.add(new NewznabAttribute("group", group));
attributes.add(new NewznabAttribute("grabs", String.valueOf(random.nextInt(1000))));
if (random.nextBoolean()) {
  attributes.add(new NewznabAttribute("nfo", String.valueOf(random.nextInt(2))));
torznabAttributes.add(new NewznabAttribute("seeders", String.valueOf(i)));
torznabAttributes.add(new NewznabAttribute("peers", String.valueOf(i * 2)));
torznabAttributes.add(new NewznabAttribute("size", size));
item.setTorznabAttributes(torznabAttributes);
origin: theotherp/nzbhydra2

attributes.add(new NewznabAttribute("category", "7000"));
attributes.add(new NewznabAttribute("size", String.valueOf(random.nextInt())));
attributes.add(new NewznabAttribute("guid", "attributeGuid" + i));
attributes.add(new NewznabAttribute("poster", "poster"));
attributes.add(new NewznabAttribute("group", "group"));
item.setNewznabAttributes(attributes);
origin: theotherp/nzbhydra2

newznabAttributes.add(new NewznabAttribute("size", String.valueOf(size)));
if (enclosure == null) {
  rssItem.setEnclosure(new NewznabXmlEnclosure(link, size, "application/x-nzb"));
newznabAttributes.add(new NewznabAttribute("usenetdate", new JaxbPubdateAdapter().marshal(pubDate)));
if (grabs != null) {
  newznabAttributes.add(new NewznabAttribute("grabs", String.valueOf(grabs)));
origin: theotherp/nzbhydra2

List<NewznabAttribute> newznabAttributes = searchResultItem.getAttributes().entrySet().stream().map(attribute -> new NewznabAttribute(attribute.getKey(), attribute.getValue())).sorted(Comparator.comparing(NewznabAttribute::getName)).collect(Collectors.toList());
newznabAttributes.add(new NewznabAttribute("hydraIndexerScore", String.valueOf(searchResultItem.getIndexer().getConfig().getScore().orElse(null))));
newznabAttributes.add(new NewznabAttribute("hydraIndexerHost", getIndexerHost(searchResultItem)));
newznabAttributes.add(new NewznabAttribute("hydraIndexerName", String.valueOf(searchResultItem.getIndexer().getName())));
String resultType;
if (isNzb) {
origin: theotherp/nzbhydra2

rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear();
rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear();
rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100"));
rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear();
rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear();
rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000"));
rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); //Otherwise it will result in a unique key exception
rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0));
origin: theotherp/nzbhydra2

  NewznabXmlItem result1 = RssItemBuilder.builder("indexer1-result1").pubDate(Instant.now().minus(1, ChronoUnit.DAYS)).hasNfo(false).grabs(1).size(mbToBytes(1)).newznabAttributes(new ArrayList<>(Arrays.asList(new NewznabAttribute("category", "5000")))).category("TV").build();
  NewznabXmlItem result2 = RssItemBuilder.builder("indexer1-result2").pubDate(Instant.now().minus(2, ChronoUnit.DAYS)).hasNfo(true).grabs(2).size(mbToBytes(2)).newznabAttributes(new ArrayList<>(Arrays.asList(new NewznabAttribute("category", "5040")))).category("TV SD").build();
  NewznabXmlItem result3 = RssItemBuilder.builder("indexer1-result3").pubDate(Instant.now().minus(3, ChronoUnit.DAYS)).comments("comments").grabs(3).size(mbToBytes(3)).newznabAttributes(new ArrayList<>(Arrays.asList(new NewznabAttribute("category", "5030")))).category("TV HD").build();
  NewznabXmlRoot rssRoot = NewznabMockBuilder.getRssRoot(Arrays.asList(result1, result2, result3), 0, 3);
  return new ResponseEntity<Object>(rssRoot, HttpStatus.OK);
NewznabXmlItem result4 = RssItemBuilder.builder("indexer2-result1").pubDate(Instant.now().minus(4, ChronoUnit.DAYS)).grabs(4).size(mbToBytes(4)).newznabAttributes(new ArrayList<>(Arrays.asList(new NewznabAttribute("category", "2000")))).category("Movies").build();
NewznabXmlItem result5 = RssItemBuilder.builder("indexer2-result2").pubDate(Instant.now().minus(5, ChronoUnit.DAYS)).grabs(5).size(mbToBytes(5)).newznabAttributes(new ArrayList<>(Arrays.asList(new NewznabAttribute("category", "2040")))).category("Movies HD").build();
NewznabXmlRoot rssRoot = NewznabMockBuilder.getRssRoot(Arrays.asList(result4, result5), 0, 2);
return new ResponseEntity<Object>(rssRoot, HttpStatus.OK);
org.nzbhydra.mapping.newznab.xmlNewznabAttribute

Most used methods

  • <init>
  • getName
  • getValue

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • JComboBox (javax.swing)
  • JFileChooser (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now