use of org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel in project nzbhydra2 by theotherp.
the class RssMappingTest method shouldParseResponseFromCardigann.
@Test
public void shouldParseResponseFromCardigann() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("btnJackettResponse.xml");
NewznabXmlChannel channel = rssRoot.getRssChannel();
assertThat(channel.getDescription(), is("Needs no description.."));
NewznabXmlResponse newznabResponse = channel.getNewznabResponse();
assertThat(newznabResponse, is(nullValue()));
List<NewznabXmlItem> items = channel.getItems();
assertThat(items.size(), is(3));
NewznabXmlItem item = items.get(0);
assertThat(item.getTitle(), is("The.Challenge.S30.Special.14.Times.Our.Challengers.Found.Their.Shit.1080p.WEB.x264-CookieMonster"));
assertThat(item.getRssGuid().getGuid(), is("https://unicasthe.net/torrents.php?action=download&id=799031&authkey=authkey&torrent_pass=torrentPass"));
assertThat(item.getLink(), startsWith("http://127.0.0.1:9117/dl/unicasthenet/jackettApiKey?path=linkstuff&file=The.Challenge.S30.Special.14.Times.Our.Challengers.Found.Their.Shit.1080p.WEB.x264-CookieMonster.torrent"));
assertThat(item.getCategory(), is("5000"));
assertThat(item.getEnclosure().getLength(), is(1459519537L));
assertThat(item.getTorznabAttributes().size(), is(6));
assertThat(item.getTorznabAttributes().get(0).getName(), is("rageid"));
assertThat(item.getTorznabAttributes().get(0).getValue(), is("6126"));
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel in project nzbhydra2 by theotherp.
the class TorznabMappingTest method testMappingFromXml.
@Test
public void testMappingFromXml() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("cardigann.xml");
NewznabXmlChannel channel = rssRoot.getRssChannel();
assertThat(channel.getTitle(), is("some-torrents"));
assertThat(channel.getLink(), is("https://some-torrents.com/"));
assertThat(channel.getLanguage(), is("en-us"));
List<NewznabXmlItem> items = channel.getItems();
assertThat(items.size(), is(2));
NewznabXmlItem item = items.get(0);
assertThat(item.getLink(), is("http://127.0.0.1:5060/download/111.torrent"));
assertThat(item.getPubDate(), is(Instant.ofEpochSecond(1493900064)));
assertThat(item.getComments(), is("https://some-torrents.com/details.php?id=111&page=0#startcomments"));
NewznabXmlGuid rssGuid = item.getRssGuid();
assertThat(rssGuid.getGuid(), is("https://some-torrents.com/details.php?id=111"));
NewznabXmlEnclosure enclosure = item.getEnclosure();
assertThat(enclosure.getUrl(), is("http://127.0.0.1:5060/download/111.torrent"));
List<NewznabAttribute> attributes = item.getTorznabAttributes();
assertThat(attributes.size(), is(8));
assertThat(attributes.get(1).getName(), is("seeders"));
assertThat(attributes.get(1).getValue(), is("11"));
assertThat(attributes.get(5).getName(), is("size"));
assertThat(attributes.get(5).getValue(), is("620000000"));
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel in project nzbhydra2 by theotherp.
the class RssChannelBuilder method build.
public NewznabXmlChannel build() {
NewznabXmlChannel rssChannel = new NewznabXmlChannel();
rssChannel.setTitle(title);
rssChannel.setDescription(description);
rssChannel.setLink(link);
rssChannel.setLanguage(language);
rssChannel.setWebMaster(webMaster);
rssChannel.setGenerator(generator);
rssChannel.setNewznabResponse(newznabResponse);
rssChannel.setItems(items);
return rssChannel;
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel in project nzbhydra2 by theotherp.
the class NewznabResponseBuilder method getTestResult.
public NewznabXmlRoot getTestResult(int startCount, int endCount, String itemTitleBase, Integer offset, Integer total) {
NewznabXmlRoot rssRoot = new NewznabXmlRoot();
rssRoot.setVersion("2.0");
NewznabXmlChannel channel = new NewznabXmlChannel();
channel.setTitle("channelTitle");
channel.setDescription("channelDescription");
channel.setLanguage("en-gb");
channel.setWebMaster("webmaster@master.com");
channel.setLink("http://www.link.xyz");
channel.setNewznabResponse(new NewznabXmlResponse(offset == null ? startCount - 1 : offset, total == null ? endCount : total));
List<NewznabXmlItem> items = new ArrayList<>();
for (int i = startCount; i <= endCount; i++) {
NewznabXmlItem item = new NewznabXmlItem();
item.setDescription("Some longer itemDescription that whatever" + i);
item.setTitle(itemTitleBase + i);
item.setPubDate(Instant.now().minus(i * 1000, ChronoUnit.HOURS));
item.setEnclosure(new NewznabXmlEnclosure("enclosureUrl", 5L, "application/x-nzb"));
item.setComments("http://www.comments.com/" + i);
item.setLink("http://www.link.com/" + i);
item.setCategory("category");
item.setRssGuid(new NewznabXmlGuid("http://www." + itemTitleBase + ".com/" + i, true));
List<NewznabAttribute> attributes = new ArrayList<>();
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);
items.add(item);
}
channel.setItems(items);
rssRoot.setRssChannel(channel);
return rssRoot;
}
use of org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel in project nzbhydra2 by theotherp.
the class RssMappingTest method testMappingFromXml.
@Test
public void testMappingFromXml() throws Exception {
NewznabXmlRoot rssRoot = getRssRootFromXml("newznab_3results.xml");
NewznabXmlChannel channel = rssRoot.getRssChannel();
assertThat(channel.getDescription(), is("indexerName(dot)com Feed"));
assertThat(channel.getLink(), is("https://indexerName.com/"));
assertThat(channel.getLanguage(), is("en-gb"));
assertThat(channel.getWebMaster(), is("admin@indexerName.com (indexerName(dot)com)"));
NewznabXmlResponse newznabResponse = channel.getNewznabResponse();
assertThat(newznabResponse.getOffset(), is(0));
assertThat(newznabResponse.getTotal(), is(1000));
List<NewznabXmlItem> items = channel.getItems();
assertThat(items.size(), is(3));
NewznabXmlItem item = items.get(0);
assertThat(item.getLink(), is("https://indexerName.com/getnzb/eff551fbdb69d6777d5030c209ee5d4b.nzb&i=1692&r=apikey"));
assertThat(item.getPubDate(), is(Instant.ofEpochSecond(1444584857)));
assertThat(item.getDescription(), is("testtitle1"));
assertThat(item.getComments(), is("https://indexerName.com/details/eff551fbdb69d6777d5030c209ee5d4b#comments"));
NewznabXmlGuid rssGuid = item.getRssGuid();
assertThat(rssGuid.getGuid(), is("eff551fbdb69d6777d5030c209ee5d4b"));
assertThat(rssGuid.isPermaLink(), is(false));
NewznabXmlEnclosure enclosure = item.getEnclosure();
assertThat(enclosure.getUrl(), is("https://indexerName.com/getnzb/eff551fbdb69d6777d5030c209ee5d4b.nzb&i=1692&r=apikey"));
assertThat(enclosure.getLength(), is(2893890900L));
List<NewznabAttribute> attributes = item.getNewznabAttributes();
assertThat(attributes.size(), is(6));
assertThat(attributes.get(0).getName(), is("category"));
assertThat(attributes.get(0).getValue(), is("7000"));
assertThat(attributes.get(2).getName(), is("size"));
assertThat(attributes.get(2).getValue(), is("2893890900"));
assertThat(attributes.get(3).getName(), is("guid"));
assertThat(attributes.get(3).getValue(), is("eff551fbdb69d6777d5030c209ee5d4b"));
assertThat(attributes.get(4).getName(), is("poster"));
assertThat(attributes.get(4).getValue(), is("chuck@norris.com"));
assertThat(attributes.get(5).getName(), is("group"));
assertThat(attributes.get(5).getValue(), is("alt.binaries.mom"));
}
Aggregations