use of org.libresonic.player.domain.PodcastEpisode 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);
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class RESTController method getNewestPodcasts.
@RequestMapping(value = "/rest/getNewestPodcasts", method = { RequestMethod.GET, RequestMethod.POST })
public void getNewestPodcasts(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
int count = getIntParameter(request, "count", 20);
NewestPodcasts result = new NewestPodcasts();
for (PodcastEpisode episode : podcastService.getNewestEpisodes(count)) {
result.getEpisode().add(createJaxbPodcastEpisode(player, username, episode));
}
Response res = createResponse();
res.setNewestPodcasts(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class RESTController method downloadPodcastEpisode.
@RequestMapping(value = "/rest/downloadPodcastEpisode", method = { RequestMethod.GET, RequestMethod.POST })
public void downloadPodcastEpisode(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
if (!user.isPodcastRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, user.getUsername() + " is not authorized to administrate podcasts.");
return;
}
int id = getRequiredIntParameter(request, "id");
PodcastEpisode episode = podcastService.getEpisode(id, true);
if (episode == null) {
error(request, response, ErrorCode.NOT_FOUND, "Podcast episode " + id + " not found.");
return;
}
podcastService.downloadEpisode(episode);
writeEmptyResponse(request, response);
}
Aggregations