Search in sources :

Example 1 with NewznabXmlGuid

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid 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"));
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabAttribute(org.nzbhydra.mapping.newznab.xml.NewznabAttribute) NewznabXmlItem(org.nzbhydra.mapping.newznab.xml.NewznabXmlItem) NewznabXmlChannel(org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel) Test(org.junit.Test)

Example 2 with NewznabXmlGuid

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid 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;
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabAttribute(org.nzbhydra.mapping.newznab.xml.NewznabAttribute) ArrayList(java.util.ArrayList) NewznabXmlItem(org.nzbhydra.mapping.newznab.xml.NewznabXmlItem) NewznabXmlChannel(org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel) NewznabXmlResponse(org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse)

Example 3 with NewznabXmlGuid

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid in project nzbhydra2 by theotherp.

the class RssItemBuilder method build.

public NewznabXmlItem build() {
    NewznabXmlItem rssItem = new NewznabXmlItem();
    rssItem.setTitle(title);
    rssItem.setLink(link);
    rssItem.setPubDate(pubDate);
    rssItem.setDescription(description);
    rssItem.setComments(comments);
    rssItem.setCategory(category);
    rssItem.setGrabs(grabs);
    rssItem.setNewznabAttributes(newznabAttributes);
    rssItem.setTorznabAttributes(torznabAttributes);
    if (rssGuid == null) {
        rssItem.setRssGuid(new NewznabXmlGuid(title + "-guid", false));
    } else {
        rssItem.setRssGuid(rssGuid);
    }
    newznabAttributes.add(new NewznabAttribute("size", String.valueOf(size)));
    if (enclosure == null) {
        rssItem.setEnclosure(new NewznabXmlEnclosure(link, size, "application/x-nzb"));
    } else {
        rssItem.setEnclosure(enclosure);
    }
    newznabAttributes.add(new NewznabAttribute("usenetdate", new JaxbPubdateAdapter().marshal(pubDate)));
    if (grabs != null) {
        newznabAttributes.add(new NewznabAttribute("grabs", String.valueOf(grabs)));
    }
    return rssItem;
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) JaxbPubdateAdapter(org.nzbhydra.mapping.newznab.xml.JaxbPubdateAdapter) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) NewznabAttribute(org.nzbhydra.mapping.newznab.xml.NewznabAttribute) NewznabXmlItem(org.nzbhydra.mapping.newznab.xml.NewznabXmlItem)

Example 4 with NewznabXmlGuid

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid in project nzbhydra2 by theotherp.

the class NzbIndexTest method shouldParseRows.

@Test
public void shouldParseRows() throws Exception {
    Instant now = Instant.now();
    String enclosureUrl = "http://nzbindex.com/download/164950363/Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL.nzb";
    String link = "http://nzbindex.com/release/164950363/Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL.nzb";
    NewznabXmlRoot root = RssBuilder.builder().items(Arrays.asList(RssItemBuilder.builder("[ Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN ] - [00/30] - \"Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN.nzb\" yEnc\n").link(link).description("<![CDATA[\n" + "<p><font color=\"gray\">alt.binaries.hdtv.x264</font><br /> <b>1.01 GB</b><br /> 7 hours<br /> <font color=\"#3DA233\">31 files (1405 parts)</font> <font color=\"gray\">by s@nd.p (SP)</font><br /> <font color=\"#E2A910\"> 1 NFO | 9 PAR2 | 1 NZB | 19 ARCHIVE</font> - <a href=\"http://nzbindex.com/nfo/164950363/Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL.nzb/?q=\" target=\"_blank\">View NFO</a></p>\n" + "]]>").category("alt.binaries.hdtv.x264").pubDate(now).rssGuid(new NewznabXmlGuid(link, true)).enclosure(new NewznabXmlEnclosure(enclosureUrl, 1089197181L, "application/x-nzb")).build())).build();
    List<SearchResultItem> items = testee.getSearchResultItems(root);
    assertThat(items.size(), is(1));
    SearchResultItem item = items.get(0);
    assertThat(item.getTitle(), is("Watchers.of.the.Universe.S02E09.1080p.WEB-DL.DD5.1.AAC2.0.H.264-YFN-0030-Watchers.of.the.Universe.S02E09.Cant.Get.You.out.of.My.Head.1080p.WEB-DL"));
    assertThat(item.getGroup().get(), is("alt.binaries.hdtv.x264"));
    assertThat(item.getPubDate(), is(now));
    assertThat(item.isAgePrecise(), is(true));
    assertThat(item.getSize(), is(1089197181L));
    assertThat(item.getIndexerGuid(), is("164950363"));
    assertThat(item.getDownloadType(), is(DownloadType.NZB));
    assertThat(item.getHasNfo(), is(HasNfo.YES));
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) Instant(java.time.Instant) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) SearchResultItem(org.nzbhydra.searching.SearchResultItem) Test(org.junit.Test)

Example 5 with NewznabXmlGuid

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid 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"));
}
Also used : NewznabXmlEnclosure(org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure) NewznabXmlGuid(org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) NewznabAttribute(org.nzbhydra.mapping.newznab.xml.NewznabAttribute) NewznabXmlItem(org.nzbhydra.mapping.newznab.xml.NewznabXmlItem) NewznabXmlChannel(org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel) NewznabXmlResponse(org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse) Test(org.junit.Test)

Aggregations

NewznabXmlEnclosure (org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure)5 NewznabXmlGuid (org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid)5 NewznabAttribute (org.nzbhydra.mapping.newznab.xml.NewznabAttribute)4 NewznabXmlItem (org.nzbhydra.mapping.newznab.xml.NewznabXmlItem)4 NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)4 Test (org.junit.Test)3 NewznabXmlChannel (org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel)3 NewznabXmlResponse (org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse)2 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 JaxbPubdateAdapter (org.nzbhydra.mapping.newznab.xml.JaxbPubdateAdapter)1 SearchResultItem (org.nzbhydra.searching.SearchResultItem)1