Search in sources :

Example 31 with NewznabXmlRoot

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

the class ExternalApiSearchingIntegrationTest method shouldConvertProvidedIdentifier.

@Test
public void shouldConvertProvidedIdentifier() throws Exception {
    prepareIndexerWithOneResponse();
    searchModuleProvider.getIndexers().get(0).getConfig().setSupportedSearchIds(Arrays.asList(IdType.IMDB));
    when(infoProvider.convert(anyMap())).thenReturn(new MediaInfo(new MovieInfo("tt1234", null, null, 0, null)));
    when(infoProvider.canConvertAny(anySet(), anySet())).thenReturn(true);
    NewznabXmlRoot root = (NewznabXmlRoot) externalApi.api(NewznabParameters.builder().tmdbid("abcd").t(ActionAttribute.MOVIE).apikey("apikey").build()).getBody();
    RecordedRequest request = webServer.takeRequest(2, TimeUnit.SECONDS);
    assertThat(request.getRequestUrl().queryParameter("imdbid")).isEqualTo("1234");
    assertThat(root.getRssChannel().getNewznabResponse().getTotal()).isEqualTo(1);
    assertThat(root.getRssChannel().getItems().size()).isEqualTo(1);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) MovieInfo(org.nzbhydra.mediainfo.MovieInfo) Test(org.junit.Test) AbstractConfigReplacingTest(org.nzbhydra.tests.AbstractConfigReplacingTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with NewznabXmlRoot

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

the class RssBuilder method build.

public NewznabXmlRoot build() {
    NewznabXmlRoot rssRoot = new NewznabXmlRoot();
    rssChannel.getItems().addAll(items);
    rssRoot.setRssChannel(rssChannel);
    return rssRoot;
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)

Example 33 with NewznabXmlRoot

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

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

the class RssMappingTest method shouldParseResponseFromNzbAG.

@Test
public void shouldParseResponseFromNzbAG() throws Exception {
    NewznabXmlRoot rssRoot = getRssRootFromXml("nzbAgResponse.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 35 with NewznabXmlRoot

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

the class RssMappingTest method shouldParseResponseFromNzbCat.

@Test
public void shouldParseResponseFromNzbCat() throws Exception {
    NewznabXmlRoot rssRoot = getRssRootFromXml("nzbCatResponse.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)

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