当前位置: 首页>>代码示例>>Java>>正文


Java PodcastEpisode类代码示例

本文整理汇总了Java中net.sourceforge.subsonic.domain.PodcastEpisode的典型用法代码示例。如果您正苦于以下问题:Java PodcastEpisode类的具体用法?Java PodcastEpisode怎么用?Java PodcastEpisode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PodcastEpisode类属于net.sourceforge.subsonic.domain包,在下文中一共展示了PodcastEpisode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: playPodcastChannel

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
public PlayQueueInfo playPodcastChannel(int id) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    List<PodcastEpisode> episodes = podcastService.getEpisodes(id);
    List<MediaFile> files = new ArrayList<MediaFile>();
    for (PodcastEpisode episode : episodes) {
        if (episode.getStatus() == PodcastStatus.COMPLETED) {
            MediaFile mediaFile = mediaFileService.getMediaFile(episode.getMediaFileId());
            if (mediaFile != null && mediaFile.isPresent()) {
                files.add(mediaFile);
            }
        }
    }
    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:18,代码来源:PlayQueueService.java

示例2: playPodcastEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
public PlayQueueInfo playPodcastEpisode(int id) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    PodcastEpisode episode = podcastService.getEpisode(id, false);
    List<PodcastEpisode> allEpisodes = podcastService.getEpisodes(episode.getChannelId());
    List<MediaFile> files = new ArrayList<MediaFile>();

    String username = securityService.getCurrentUsername(request);
    boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs();

    for (PodcastEpisode ep : allEpisodes) {
        if (ep.getStatus() == PodcastStatus.COMPLETED) {
            MediaFile mediaFile = mediaFileService.getMediaFile(ep.getMediaFileId());
            if (mediaFile != null && mediaFile.isPresent() &&
                (ep.getId().equals(episode.getId()) || queueFollowingSongs && !files.isEmpty())) {
                files.add(mediaFile);
            }
        }
    }
    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:24,代码来源:PlayQueueService.java

示例3: playNewestPodcastEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
public PlayQueueInfo playNewestPodcastEpisode(Integer index) throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    List<PodcastEpisode> episodes = podcastService.getNewestEpisodes(10);
    List<MediaFile> files = Lists.transform(episodes, new Function<PodcastEpisode, MediaFile>() {
        @Override
        public MediaFile apply(PodcastEpisode episode) {
            return mediaFileService.getMediaFile(episode.getMediaFileId());
        }
    });

    String username = securityService.getCurrentUsername(request);
    boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs();

    if (!files.isEmpty() && index != null) {
        if (queueFollowingSongs) {
            files = files.subList(index, files.size());
        } else {
            files = Arrays.asList(files.get(index));
        }
    }

    Player player = getCurrentPlayer(request, response);
    return doPlay(request, player, files).setStartPlayerAt(0);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:27,代码来源:PlayQueueService.java

示例4: getNewestPodcasts

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
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);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:18,代码来源:RESTController.java

示例5: createJaxbPodcastEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
private org.subsonic.restapi.PodcastEpisode createJaxbPodcastEpisode(Player player, String username, PodcastEpisode episode) {
    org.subsonic.restapi.PodcastEpisode e = new org.subsonic.restapi.PodcastEpisode();

    String path = episode.getPath();
    if (path != null) {
        MediaFile mediaFile = mediaFileService.getMediaFile(path);
        e = createJaxbChild(new org.subsonic.restapi.PodcastEpisode(), player, mediaFile, username);
        e.setStreamId(String.valueOf(mediaFile.getId()));
    }

    e.setId(String.valueOf(episode.getId()));  // Overwrites the previous "id" attribute.
    e.setChannelId(String.valueOf(episode.getChannelId()));
    e.setStatus(PodcastStatus.valueOf(episode.getStatus().name()));
    e.setTitle(episode.getTitle());
    e.setDescription(episode.getDescription());
    e.setPublishDate(jaxbWriter.convertDate(episode.getPublishDate()));
    return e;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:19,代码来源:RESTController.java

示例6: downloadPodcastEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
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);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:20,代码来源:RESTController.java

示例7: handleRequestInternal

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

    Map<String, Object> map = new HashMap<String, Object>();
    ModelAndView result = super.handleRequestInternal(request, response);
    result.addObject("model", map);

    Map<PodcastChannel, List<PodcastEpisode>> channels = new LinkedHashMap<PodcastChannel, List<PodcastEpisode>>();
    Map<Integer, PodcastChannel> channelMap = new HashMap<Integer, PodcastChannel>();
    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));
    map.put("licenseInfo", settingsService.getLicenseInfo());
    return result;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:22,代码来源:PodcastChannelsController.java

示例8: init

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
public synchronized void init() {
    try {
        // Clean up partial downloads.
        for (PodcastChannel channel : getAllChannels()) {
            for (PodcastEpisode episode : getEpisodes(channel.getId())) {
                if (episode.getStatus() == PodcastStatus.DOWNLOADING) {
                    deleteEpisode(episode.getId(), false);
                    LOG.info("Deleted Podcast episode '" + episode.getTitle() + "' since download was interrupted.");
                }
            }
        }
        schedule();
    } catch (Throwable x) {
        LOG.error("Failed to initialize PodcastService: " + x, x);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:17,代码来源:PodcastService.java

示例9: getNewestEpisodes

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
/**
 * 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();
        }
    }));
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:22,代码来源:PodcastService.java

示例10: updateTags

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
private void updateTags(File file, PodcastEpisode episode) {
    try {
        MediaFile mediaFile = mediaFileService.getMediaFile(file, false);
        if (StringUtils.isNotBlank(episode.getTitle())) {
            MetaDataParser parser = metaDataParserFactory.getParser(file);
            if (!parser.isEditingSupported()) {
                return;
            }
            MetaData metaData = parser.getRawMetaData(file);
            metaData.setTitle(episode.getTitle());
            parser.setMetaData(mediaFile, metaData);
            mediaFileService.refreshMediaFile(mediaFile);
        }
    } catch (Exception x) {
        LOG.warn("Failed to update tags for podcast " + episode.getUrl(), x);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:18,代码来源:PodcastService.java

示例11: deleteObsoleteEpisodes

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
private synchronized void deleteObsoleteEpisodes(PodcastChannel channel) {
    int episodeCount = settingsService.getPodcastEpisodeRetentionCount();
    if (episodeCount == -1) {
        return;
    }

    List<PodcastEpisode> episodes = getEpisodes(channel.getId());

    // Don't do anything if other episodes of the same channel is currently downloading.
    for (PodcastEpisode episode : episodes) {
        if (episode.getStatus() == PodcastStatus.DOWNLOADING) {
            return;
        }
    }

    // Reverse array to get chronological order (oldest episodes first).
    Collections.reverse(episodes);

    int episodesToDelete = Math.max(0, episodes.size() - episodeCount);
    for (int i = 0; i < episodesToDelete; i++) {
        deleteEpisode(episodes.get(i).getId(), true);
        LOG.info("Deleted old Podcast episode " + episodes.get(i).getUrl());
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:25,代码来源:PodcastService.java

示例12: getFile

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
private synchronized File getFile(PodcastChannel channel, PodcastEpisode episode) {

        File channelDir = getChannelDirectory(channel);

        String filename = StringUtil.getUrlFile(episode.getUrl());
        if (filename == null) {
            filename = episode.getTitle();
        }
        filename = StringUtil.fileSystemSafe(filename);
        String extension = FilenameUtils.getExtension(filename);
        filename = FilenameUtils.removeExtension(filename);
        if (StringUtils.isBlank(extension)) {
            extension = "mp3";
        }

        File file = new File(channelDir, filename + "." + extension);
        for (int i = 0; file.exists(); i++) {
            file = new File(channelDir, filename + i + "." + extension);
        }

        if (!securityService.isWriteAllowed(file)) {
            throw new SecurityException("Access denied to file " + file);
        }
        return file;
    }
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:26,代码来源:PodcastService.java

示例13: deleteEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
/**
 * Deletes the Podcast episode with the given ID.
 *
 * @param episodeId     The Podcast episode ID.
 * @param logicalDelete Whether to perform a logical delete by setting the
 *                      episode status to {@link PodcastStatus#DELETED}.
 */
public void deleteEpisode(int episodeId, boolean logicalDelete) {
    PodcastEpisode episode = podcastDao.getEpisode(episodeId);
    if (episode == null) {
        return;
    }

    // Delete file.
    if (episode.getPath() != null) {
        File file = new File(episode.getPath());
        if (file.exists()) {
            file.delete();
            // TODO: Delete directory if empty?
        }
    }

    if (logicalDelete) {
        episode.setStatus(PodcastStatus.DELETED);
        episode.setErrorMessage(null);
        podcastDao.updateEpisode(episode);
    } else {
        podcastDao.deleteEpisode(episodeId);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:31,代码来源:PodcastService.java

示例14: testGetEpisodes

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
public void testGetEpisodes() {
    int channelId = createChannel();
    PodcastEpisode a = new PodcastEpisode(null, channelId, "a", null, null, null,
            new Date(3000), null, null, null, PodcastStatus.NEW, null);
    PodcastEpisode b = new PodcastEpisode(null, channelId, "b", null, null, null,
            new Date(1000), null, null, null, PodcastStatus.NEW, "error");
    PodcastEpisode c = new PodcastEpisode(null, channelId, "c", null, null, null,
            new Date(2000), null, null, null, PodcastStatus.NEW, null);
    PodcastEpisode d = new PodcastEpisode(null, channelId, "c", null, null, null,
            null, null, null, null, PodcastStatus.NEW, "");
    podcastDao.createEpisode(a);
    podcastDao.createEpisode(b);
    podcastDao.createEpisode(c);
    podcastDao.createEpisode(d);

    List<PodcastEpisode> episodes = podcastDao.getEpisodes(channelId);
    assertEquals("Error in getEpisodes().", 4, episodes.size());
    assertEpisodeEquals(a, episodes.get(0));
    assertEpisodeEquals(c, episodes.get(1));
    assertEpisodeEquals(b, episodes.get(2));
    assertEpisodeEquals(d, episodes.get(3));
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:23,代码来源:PodcastDaoTestCase.java

示例15: testUpdateEpisode

import net.sourceforge.subsonic.domain.PodcastEpisode; //导入依赖的package包/类
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);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:24,代码来源:PodcastDaoTestCase.java


注:本文中的net.sourceforge.subsonic.domain.PodcastEpisode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。