本文整理汇总了Java中net.sourceforge.subsonic.domain.PodcastStatus类的典型用法代码示例。如果您正苦于以下问题:Java PodcastStatus类的具体用法?Java PodcastStatus怎么用?Java PodcastStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PodcastStatus类属于net.sourceforge.subsonic.domain包,在下文中一共展示了PodcastStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playPodcastChannel
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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);
}
示例2: playPodcastEpisode
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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);
}
示例3: init
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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);
}
}
示例4: deleteObsoleteEpisodes
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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());
}
}
示例5: deleteEpisode
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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);
}
}
示例6: testUpdateChannel
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
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);
}
示例7: testGetEpisodes
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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));
}
示例8: testUpdateEpisode
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的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);
}
示例9: testDeleteEpisode
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
public void testDeleteEpisode() {
int channelId = createChannel();
assertEquals("Wrong number of episodes.", 0, podcastDao.getEpisodes(channelId).size());
PodcastEpisode episode = new PodcastEpisode(null, channelId, "http://bar", null, null, null,
null, null, null, null, PodcastStatus.NEW, null);
podcastDao.createEpisode(episode);
assertEquals("Wrong number of episodes.", 1, podcastDao.getEpisodes(channelId).size());
podcastDao.createEpisode(episode);
assertEquals("Wrong number of episodes.", 2, podcastDao.getEpisodes(channelId).size());
podcastDao.deleteEpisode(podcastDao.getEpisodes(channelId).get(0).getId());
assertEquals("Wrong number of episodes.", 1, podcastDao.getEpisodes(channelId).size());
podcastDao.deleteEpisode(podcastDao.getEpisodes(channelId).get(0).getId());
assertEquals("Wrong number of episodes.", 0, podcastDao.getEpisodes(channelId).size());
}
示例10: init
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
public synchronized void init() {
try {
// Clean up partial downloads.
for (PodcastChannel channel : getAllChannels()) {
for (PodcastEpisode episode : getEpisodes(channel.getId(), false)) {
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);
}
}
示例11: getEpisodes
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
/**
* Returns all Podcast episodes for a given channel.
*
* @param channelId The Podcast channel ID.
* @param includeDeleted Whether to include logically deleted episodes in the result.
* @return Possibly empty list of all Podcast episodes for the given channel, sorted in
* reverse chronological order (newest episode first).
*/
public List<PodcastEpisode> getEpisodes(int channelId, boolean includeDeleted) {
List<PodcastEpisode> all = filterAllowed(podcastDao.getEpisodes(channelId));
addMediaFileIdToEpisodes(all);
if (includeDeleted) {
return all;
}
List<PodcastEpisode> filtered = new ArrayList<PodcastEpisode>();
for (PodcastEpisode episode : all) {
if (episode.getStatus() != PodcastStatus.DELETED) {
filtered.add(episode);
}
}
return filtered;
}
示例12: deleteObsoleteEpisodes
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
private synchronized void deleteObsoleteEpisodes(PodcastChannel channel) {
int episodeCount = settingsService.getPodcastEpisodeRetentionCount();
if (episodeCount == -1) {
return;
}
List<PodcastEpisode> episodes = getEpisodes(channel.getId(), false);
// 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());
}
}
示例13: testUpdateChannel
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
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.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);
}
示例14: download
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
private void download(int[] episodeIds) {
for (Integer episodeId : episodeIds) {
PodcastEpisode episode = podcastService.getEpisode(episodeId, false);
if (episode != null && episode.getUrl() != null &&
(episode.getStatus() == PodcastStatus.NEW ||
episode.getStatus() == PodcastStatus.ERROR ||
episode.getStatus() == PodcastStatus.SKIPPED)) {
podcastService.downloadEpisode(episode);
}
}
}
示例15: getEpisode
import net.sourceforge.subsonic.domain.PodcastStatus; //导入依赖的package包/类
public PodcastEpisode getEpisode(int episodeId, boolean includeDeleted) {
PodcastEpisode episode = podcastDao.getEpisode(episodeId);
if (episode == null) {
return null;
}
if (episode.getStatus() == PodcastStatus.DELETED && !includeDeleted) {
return null;
}
addMediaFileIdToEpisodes(Arrays.asList(episode));
return episode;
}