Search in sources :

Example 11 with PodcastChannel

use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.

the class PodcastDaoTestCase method testCreateChannel.

@Test
public void testCreateChannel() {
    PodcastChannel channel = new PodcastChannel("http://foo");
    podcastDao.createChannel(channel);
    PodcastChannel newChannel = podcastDao.getAllChannels().get(0);
    assertNotNull("Wrong ID.", newChannel.getId());
    assertChannelEquals(channel, newChannel);
}
Also used : PodcastChannel(org.libresonic.player.domain.PodcastChannel) Test(org.junit.Test)

Example 12 with PodcastChannel

use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.

the class PodcastDaoTestCase method testDeleteChannel.

@Test
public void testDeleteChannel() {
    assertEquals("Wrong number of channels.", 0, podcastDao.getAllChannels().size());
    PodcastChannel channel = new PodcastChannel("http://foo");
    podcastDao.createChannel(channel);
    assertEquals("Wrong number of channels.", 1, podcastDao.getAllChannels().size());
    podcastDao.createChannel(channel);
    assertEquals("Wrong number of channels.", 2, podcastDao.getAllChannels().size());
    podcastDao.deleteChannel(podcastDao.getAllChannels().get(0).getId());
    assertEquals("Wrong number of channels.", 1, podcastDao.getAllChannels().size());
    podcastDao.deleteChannel(podcastDao.getAllChannels().get(0).getId());
    assertEquals("Wrong number of channels.", 0, podcastDao.getAllChannels().size());
}
Also used : PodcastChannel(org.libresonic.player.domain.PodcastChannel) Test(org.junit.Test)

Example 13 with PodcastChannel

use of org.libresonic.player.domain.PodcastChannel in project libresonic by Libresonic.

the class RESTController method getPodcasts.

@RequestMapping(value = "/rest/getPodcasts", method = { RequestMethod.GET, RequestMethod.POST })
public void getPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    Player player = playerService.getPlayer(request, response);
    String username = securityService.getCurrentUsername(request);
    boolean includeEpisodes = getBooleanParameter(request, "includeEpisodes", true);
    Integer channelId = getIntParameter(request, "id");
    Podcasts result = new Podcasts();
    for (PodcastChannel channel : podcastService.getAllChannels()) {
        if (channelId == null || channelId.equals(channel.getId())) {
            org.libresonic.restapi.PodcastChannel c = new org.libresonic.restapi.PodcastChannel();
            result.getChannel().add(c);
            c.setId(String.valueOf(channel.getId()));
            c.setUrl(channel.getUrl());
            c.setStatus(PodcastStatus.valueOf(channel.getStatus().name()));
            c.setTitle(channel.getTitle());
            c.setDescription(channel.getDescription());
            c.setCoverArt(CoverArtController.PODCAST_COVERART_PREFIX + channel.getId());
            c.setOriginalImageUrl(channel.getImageUrl());
            c.setErrorMessage(channel.getErrorMessage());
            if (includeEpisodes) {
                List<PodcastEpisode> episodes = podcastService.getEpisodes(channel.getId());
                for (PodcastEpisode episode : episodes) {
                    c.getEpisode().add(createJaxbPodcastEpisode(player, username, episode));
                }
            }
        }
    }
    Response res = createResponse();
    res.setPodcasts(result);
    jaxbWriter.writeResponse(request, response, res);
}
Also used : org.libresonic.restapi(org.libresonic.restapi) PodcastChannel(org.libresonic.player.domain.PodcastChannel) PodcastEpisode(org.libresonic.player.domain.PodcastEpisode) HttpServletResponse(javax.servlet.http.HttpServletResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PodcastChannel (org.libresonic.player.domain.PodcastChannel)13 Test (org.junit.Test)4 File (java.io.File)2 MediaFile (org.libresonic.player.domain.MediaFile)2 PodcastEpisode (org.libresonic.player.domain.PodcastEpisode)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 RequestConfig (org.apache.http.client.config.RequestConfig)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 org.libresonic.restapi (org.libresonic.restapi)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1