Search in sources :

Example 6 with PodcastEpisode

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);
}
Also used : Date(java.util.Date) PodcastEpisode(org.libresonic.player.domain.PodcastEpisode) Test(org.junit.Test)

Example 7 with PodcastEpisode

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());
}
Also used : PodcastEpisode(org.libresonic.player.domain.PodcastEpisode) Test(org.junit.Test)

Example 8 with PodcastEpisode

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);
}
Also used : Date(java.util.Date) PodcastEpisode(org.libresonic.player.domain.PodcastEpisode) Test(org.junit.Test)

Example 9 with PodcastEpisode

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();
        }
    }));
}
Also used : MediaFile(org.libresonic.player.domain.MediaFile) PodcastEpisode(org.libresonic.player.domain.PodcastEpisode) Predicate(com.google.common.base.Predicate)

Example 10 with PodcastEpisode

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);
}
Also used : PodcastEpisode(org.libresonic.player.domain.PodcastEpisode)

Aggregations

PodcastEpisode (org.libresonic.player.domain.PodcastEpisode)18 Test (org.junit.Test)6 Date (java.util.Date)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Element (org.jdom.Element)2 MediaFile (org.libresonic.player.domain.MediaFile)2 PodcastChannel (org.libresonic.player.domain.PodcastChannel)2 Predicate (com.google.common.base.Predicate)1 File (java.io.File)1 InputStream (java.io.InputStream)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 Document (org.jdom.Document)1 SAXBuilder (org.jdom.input.SAXBuilder)1 User (org.libresonic.player.domain.User)1 org.libresonic.restapi (org.libresonic.restapi)1