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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations