use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class PodcastDaoTestCase method testUpdateEpisode.
@Test
public void testUpdateEpisode() {
int channelId = createChannel();
PodcastEpisode episode = new PodcastEpisode(null, channelId, "http://bar", null, null, null, null, null, null, null, PodcastStatus.NEW, null);
podcastDao.createEpisode(episode);
episode = podcastDao.getEpisodes(channelId).get(0);
episode.setUrl("http://bar");
episode.setPath("c:/tmp");
episode.setTitle("Title");
episode.setDescription("Description");
episode.setPublishDate(new Date());
episode.setDuration("1:20");
episode.setBytesTotal(87628374612L);
episode.setBytesDownloaded(9086L);
episode.setStatus(PodcastStatus.DOWNLOADING);
episode.setErrorMessage("Some error");
podcastDao.updateEpisode(episode);
PodcastEpisode newEpisode = podcastDao.getEpisodes(channelId).get(0);
assertEquals("Wrong ID.", episode.getId(), newEpisode.getId());
assertEpisodeEquals(episode, newEpisode);
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class PodcastDaoTestCase method testCascadingDelete.
@Test
public void testCascadingDelete() {
int channelId = createChannel();
PodcastEpisode episode = new PodcastEpisode(null, channelId, "http://bar", null, null, null, null, null, null, null, PodcastStatus.NEW, null);
podcastDao.createEpisode(episode);
podcastDao.createEpisode(episode);
assertEquals("Wrong number of episodes.", 2, podcastDao.getEpisodes(channelId).size());
podcastDao.deleteChannel(channelId);
assertEquals("Wrong number of episodes.", 0, podcastDao.getEpisodes(channelId).size());
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class PodcastDaoTestCase method testCreateEpisode.
@Test
public void testCreateEpisode() {
int channelId = createChannel();
PodcastEpisode episode = new PodcastEpisode(null, channelId, "http://bar", "path", "title", "description", new Date(), "12:34", null, null, PodcastStatus.NEW, null);
podcastDao.createEpisode(episode);
PodcastEpisode newEpisode = podcastDao.getEpisodes(channelId).get(0);
assertNotNull("Wrong ID.", newEpisode.getId());
assertEpisodeEquals(episode, newEpisode);
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class PodcastService method getNewestEpisodes.
/**
* Returns the N newest episodes.
*
* @return Possibly empty list of the newest Podcast episodes, sorted in
* reverse chronological order (newest episode first).
*/
public List<PodcastEpisode> getNewestEpisodes(int count) {
List<PodcastEpisode> episodes = addMediaFileIdToEpisodes(podcastDao.getNewestEpisodes(count));
return Lists.newArrayList(Iterables.filter(episodes, new Predicate<PodcastEpisode>() {
@Override
public boolean apply(PodcastEpisode episode) {
Integer mediaFileId = episode.getMediaFileId();
if (mediaFileId == null) {
return false;
}
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
return mediaFile != null && mediaFile.isPresent();
}
}));
}
use of org.libresonic.player.domain.PodcastEpisode in project libresonic by Libresonic.
the class PodcastService method deleteChannel.
/**
* Deletes the Podcast channel with the given ID.
*
* @param channelId The Podcast channel ID.
*/
public void deleteChannel(int channelId) {
// Delete all associated episodes (in case they have files that need to be deleted).
List<PodcastEpisode> episodes = getEpisodes(channelId);
for (PodcastEpisode episode : episodes) {
deleteEpisode(episode.getId(), false);
}
podcastDao.deleteChannel(channelId);
}
Aggregations