Search in sources :

Example 1 with PodcastChannel

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

the class PodcastService method getChannel.

/**
     * Returns a single Podcast channel.
     */
public PodcastChannel getChannel(int channelId) {
    PodcastChannel channel = podcastDao.getChannel(channelId);
    addMediaFileIdToChannels(Arrays.asList(channel));
    return channel;
}
Also used : PodcastChannel(org.libresonic.player.domain.PodcastChannel)

Example 2 with PodcastChannel

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

the class PodcastService method addMediaFileIdToChannels.

private List<PodcastChannel> addMediaFileIdToChannels(List<PodcastChannel> channels) {
    for (PodcastChannel channel : channels) {
        try {
            File dir = getChannelDirectory(channel);
            MediaFile mediaFile = mediaFileService.getMediaFile(dir);
            if (mediaFile != null) {
                channel.setMediaFileId(mediaFile.getId());
            }
        } catch (Exception x) {
            LOG.warn("Failed to resolve media file ID for podcast channel '" + channel.getTitle() + "': " + x, x);
        }
    }
    return channels;
}
Also used : MediaFile(org.libresonic.player.domain.MediaFile) PodcastChannel(org.libresonic.player.domain.PodcastChannel) MediaFile(org.libresonic.player.domain.MediaFile) File(java.io.File)

Example 3 with PodcastChannel

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

the class PodcastService method createChannel.

/**
     * Creates a new Podcast channel.
     *
     * @param url The URL of the Podcast channel.
     */
public void createChannel(String url) {
    url = sanitizeUrl(url);
    PodcastChannel channel = new PodcastChannel(url);
    int channelId = podcastDao.createChannel(channel);
    refreshChannels(Arrays.asList(getChannel(channelId)), true);
}
Also used : PodcastChannel(org.libresonic.player.domain.PodcastChannel)

Example 4 with PodcastChannel

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

the class PodcastChannelsController method handleRequestInternal.

@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> map = new HashMap<>();
    ModelAndView result = new ModelAndView();
    result.addObject("model", map);
    Map<PodcastChannel, List<PodcastEpisode>> channels = new LinkedHashMap<>();
    Map<Integer, PodcastChannel> channelMap = new HashMap<>();
    for (PodcastChannel channel : podcastService.getAllChannels()) {
        channels.put(channel, podcastService.getEpisodes(channel.getId()));
        channelMap.put(channel.getId(), channel);
    }
    map.put("user", securityService.getCurrentUser(request));
    map.put("channels", channels);
    map.put("channelMap", channelMap);
    map.put("newestEpisodes", podcastService.getNewestEpisodes(10));
    return result;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) PodcastChannel(org.libresonic.player.domain.PodcastChannel) LinkedHashMap(java.util.LinkedHashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PodcastChannel

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

the class PodcastDaoTestCase method testUpdateChannel.

@Test
public void testUpdateChannel() {
    PodcastChannel channel = new PodcastChannel("http://foo");
    podcastDao.createChannel(channel);
    channel = podcastDao.getAllChannels().get(0);
    channel.setUrl("http://bar");
    channel.setTitle("Title");
    channel.setDescription("Description");
    channel.setImageUrl("http://foo/bar.jpg");
    channel.setStatus(PodcastStatus.ERROR);
    channel.setErrorMessage("Something went terribly wrong.");
    podcastDao.updateChannel(channel);
    PodcastChannel newChannel = podcastDao.getAllChannels().get(0);
    assertEquals("Wrong ID.", channel.getId(), newChannel.getId());
    assertChannelEquals(channel, newChannel);
}
Also used : PodcastChannel(org.libresonic.player.domain.PodcastChannel) Test(org.junit.Test)

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