Search in sources :

Example 6 with NewznabXmlRoot

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot 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"));
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) 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)

Example 7 with NewznabXmlRoot

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

the class RssMappingTest method shouldParseResponseFromOmgwtf.

@Test
public void shouldParseResponseFromOmgwtf() throws Exception {
    NewznabXmlRoot rssRoot = getRssRootFromXml("omgwtfResponse.xml");
    assertEquals(Integer.valueOf(416), rssRoot.getRssChannel().getNewznabResponse().getTotal());
    assertNotNull(rssRoot.getRssChannel().getItems().get(0).getPubDate());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) Test(org.junit.Test)

Example 8 with NewznabXmlRoot

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

the class RssMappingTest method shouldParseResponseFromDrunkenSlug.

@Test
public void shouldParseResponseFromDrunkenSlug() throws Exception {
    NewznabXmlRoot rssRoot = getRssRootFromXml("drunkenSlugResponse.xml");
    assertEquals(Integer.valueOf(125000), rssRoot.getRssChannel().getNewznabResponse().getTotal());
    assertNotNull(rssRoot.getRssChannel().getItems().get(0).getPubDate());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) Test(org.junit.Test)

Example 9 with NewznabXmlRoot

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

the class RssMappingTest method shouldSerializeToJson.

@Test
public void shouldSerializeToJson() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    NewznabXmlRoot rssRoot = getRssRootFromXml("newznab_3results.xml");
    String json = objectMapper.writeValueAsString(rssRoot);
    System.out.println(json);
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 10 with NewznabXmlRoot

use of org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot 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)

Aggregations

NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)41 Test (org.junit.Test)30 MockResponse (okhttp3.mockwebserver.MockResponse)12 NewznabXmlItem (org.nzbhydra.mapping.newznab.xml.NewznabXmlItem)11 AbstractConfigReplacingTest (org.nzbhydra.tests.AbstractConfigReplacingTest)10 NewznabAttribute (org.nzbhydra.mapping.newznab.xml.NewznabAttribute)8 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ArrayList (java.util.ArrayList)5 Dispatcher (okhttp3.mockwebserver.Dispatcher)4 NewznabXmlChannel (org.nzbhydra.mapping.newznab.xml.NewznabXmlChannel)4 NzbhydraMockMvcTest (org.nzbhydra.tests.NzbhydraMockMvcTest)4 URI (java.net.URI)3 NewznabResponseBuilder (org.nzbhydra.fortests.NewznabResponseBuilder)3 NewznabParameters (org.nzbhydra.mapping.newznab.NewznabParameters)3 NewznabXmlEnclosure (org.nzbhydra.mapping.newznab.xml.NewznabXmlEnclosure)3 NewznabXmlGuid (org.nzbhydra.mapping.newznab.xml.NewznabXmlGuid)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Matcher (java.util.regex.Matcher)2 NewznabXmlResponse (org.nzbhydra.mapping.newznab.xml.NewznabXmlResponse)2