本文整理汇总了Java中net.sourceforge.subsonic.service.metadata.MetaData类的典型用法代码示例。如果您正苦于以下问题:Java MetaData类的具体用法?Java MetaData怎么用?Java MetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetaData类属于net.sourceforge.subsonic.service.metadata包,在下文中一共展示了MetaData类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTags
import net.sourceforge.subsonic.service.metadata.MetaData; //导入依赖的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);
}
}
示例2: handleRequestInternal
import net.sourceforge.subsonic.service.metadata.MetaData; //导入依赖的package包/类
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
int mediaFileId = NumberUtils.toInt(request.getParameter("id"));
if (mediaFileId > 0) {
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
MetaData metaData = null;
String lyrics = null;
MetaDataParser parser = metaDataParserFactory.getParser(mediaFile.getFile());
if (parser != null) {
metaData = parser.getMetaData(mediaFile.getFile());
lyrics = metaData.getLyrics();
map.put("lyrics", lyrics);
}
}
map.put("artist", request.getParameter("artist"));
map.put("song", request.getParameter("song"));
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
}
示例3: getLyrics
import net.sourceforge.subsonic.service.metadata.MetaData; //导入依赖的package包/类
public LyricsInfo getLyrics(String id, String artistname, String songname) throws SocketException {
LyricsInfo lyrics = new LyricsInfo();
String lyric = null;
try {
int mediaFileId = NumberUtils.toInt(id);
if (mediaFileId > 0) {
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
MetaData metaData = null;
MetaDataParser parser = metaDataParserFactory.getParser(mediaFile.getFile());
if (parser != null) {
metaData = parser.getMetaData(mediaFile.getFile());
lyric = metaData.getLyrics();
}
if (lyric == null){
String artist = StringUtil.urlEncode(artistname);
String song = StringUtil.urlEncode(songname);
String url = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=" + artist + "&song=" + song;
String xml = executeGetRequest(url);
lyrics = parseSearchResult(xml);
return lyrics;
}
}
} catch (Exception x) {
LOG.warn("Failed to get lyrics for id '" + id + "'.", x);
}
return new LyricsInfo(lyric, artistname, songname);
}
示例4: updateTags
import net.sourceforge.subsonic.service.metadata.MetaData; //导入依赖的package包/类
private void updateTags(File file, PodcastEpisode episode) {
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);
}
}
示例5: convert
import net.sourceforge.subsonic.service.metadata.MetaData; //导入依赖的package包/类
private List<NowPlayingInfo> convert(List<TransferStatus> statuses) throws Exception {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
String url = request.getRequestURL().toString();
List<NowPlayingInfo> result = new ArrayList<NowPlayingInfo>();
for (TransferStatus status : statuses) {
Player player = status.getPlayer();
File file = status.getFile();
if (player != null && player.getUsername() != null && file != null) {
String username = player.getUsername();
UserSettings userSettings = settingsService.getUserSettings(username);
if (!userSettings.isNowPlayingAllowed()) {
continue;
}
MediaFile mediaFile = mediaFileService.getMediaFile(file);
File coverArt = mediaFileService.getCoverArt(mediaFile);
String artist = mediaFile.getArtist();
String title = mediaFile.getTitle();
String streamUrl = url.replaceFirst("/dwr/.*", "/stream?player=" + player.getId() + "&id=" + mediaFile.getId());
String albumUrl = url.replaceFirst("/dwr/.*", "/main.view?id=" + mediaFile.getId());
MetaDataParser parser = metaDataParserFactory.getParser(mediaFile.getFile());
MetaData metaData = parser.getMetaData(mediaFile.getFile());
String lyricsUrl;
if (metaData.hasLyrics()) {
lyricsUrl = "lyrics.view?id=" + mediaFile.getId();
} else {
lyricsUrl = url.replaceFirst("/dwr/.*", "/lyrics.view?artistUtf8Hex=" + StringUtil.utf8HexEncode(artist) + "&songUtf8Hex=" + StringUtil.utf8HexEncode(title));
}
// String coverArtUrl = coverArt == null ? null : url.replaceFirst("/dwr/.*", "/coverArt.view?size=48&id=" + mediaFile.getId());
// String coverArtZoomUrl = coverArt == null ? null : url.replaceFirst("/dwr/.*", "/coverArt.view?id=" + mediaFile.getId());
String coverArtUrl = url.replaceFirst("/dwr/.*", "/coverArt.view?size=48&id=" + mediaFile.getId());
String coverArtZoomUrl = url.replaceFirst("/dwr/.*", "/coverArt.view?id=" + mediaFile.getId());
String avatarUrl = null;
if (userSettings.getAvatarScheme() == AvatarScheme.SYSTEM) {
avatarUrl = url.replaceFirst("/dwr/.*", "/avatar.view?id=" + userSettings.getSystemAvatarId());
} else if (userSettings.getAvatarScheme() == AvatarScheme.CUSTOM && settingsService.getCustomAvatar(username) != null) {
avatarUrl = url.replaceFirst("/dwr/.*", "/avatar.view?username=" + username);
}
// Rewrite URLs in case we're behind a proxy.
if (settingsService.isRewriteUrlEnabled()) {
String referer = request.getHeader("referer");
streamUrl = StringUtil.rewriteUrl(streamUrl, referer);
albumUrl = StringUtil.rewriteUrl(albumUrl, referer);
lyricsUrl = StringUtil.rewriteUrl(lyricsUrl, referer);
coverArtUrl = StringUtil.rewriteUrl(coverArtUrl, referer);
coverArtZoomUrl = StringUtil.rewriteUrl(coverArtZoomUrl, referer);
avatarUrl = StringUtil.rewriteUrl(avatarUrl, referer);
}
String tooltip = StringUtil.toHtml(artist) + " – " + StringUtil.toHtml(title);
if (StringUtils.isNotBlank(player.getName())) {
username += "@" + player.getName();
}
artist = StringUtil.toHtml(StringUtils.abbreviate(artist, 25));
title = StringUtil.toHtml(StringUtils.abbreviate(title, 25));
username = StringUtil.toHtml(StringUtils.abbreviate(username, 25));
long minutesAgo = status.getMillisSinceLastUpdate() / 1000L / 60L;
if (minutesAgo < 60) {
result.add(new NowPlayingInfo(username, artist, title, tooltip, streamUrl, albumUrl, lyricsUrl,
coverArtUrl, coverArtZoomUrl, avatarUrl, (int) minutesAgo));
}
}
}
return result;
}