use of org.libresonic.player.domain.MediaFile in project libresonic by Libresonic.
the class MultiService method getTopSongs.
private List<TopSong> getTopSongs(MediaFile mediaFile, int limit) {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
String username = securityService.getCurrentUsername(request);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<TopSong> result = new ArrayList<TopSong>();
List<MediaFile> files = lastFmService.getTopSongs(mediaFile, limit, musicFolders);
mediaFileService.populateStarredDate(files, username);
for (MediaFile file : files) {
result.add(new TopSong(file.getId(), file.getTitle(), file.getArtist(), file.getAlbumName(), file.getDurationString(), file.getStarredDate() != null));
}
return result;
}
use of org.libresonic.player.domain.MediaFile in project libresonic by Libresonic.
the class MultiService method getArtistInfo.
public ArtistInfo getArtistInfo(int mediaFileId, int maxSimilarArtists, int maxTopSongs) {
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
List<SimilarArtist> similarArtists = getSimilarArtists(mediaFileId, maxSimilarArtists);
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile);
List<TopSong> topSongs = getTopSongs(mediaFile, maxTopSongs);
return new ArtistInfo(similarArtists, artistBio, topSongs);
}
use of org.libresonic.player.domain.MediaFile in project libresonic by Libresonic.
the class PlaylistService method createPlaylistForStarredSongs.
public int createPlaylistForStarredSongs() {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
Locale locale = localeResolver.resolveLocale(request);
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);
Date now = new Date();
Playlist playlist = new Playlist();
String username = securityService.getCurrentUsername(request);
playlist.setUsername(username);
playlist.setCreated(now);
playlist.setChanged(now);
playlist.setShared(false);
ResourceBundle bundle = ResourceBundle.getBundle("org.libresonic.player.i18n.ResourceBundle", locale);
playlist.setName(bundle.getString("top.starred") + " " + dateFormat.format(now));
playlistService.createPlaylist(playlist);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<MediaFile> songs = mediaFileDao.getStarredFiles(0, Integer.MAX_VALUE, username, musicFolders);
playlistService.setFilesInPlaylist(playlist.getId(), songs);
return playlist.getId();
}
use of org.libresonic.player.domain.MediaFile in project libresonic by Libresonic.
the class PlaylistService method appendToPlaylist.
public void appendToPlaylist(int playlistId, List<Integer> mediaFileIds) {
List<MediaFile> files = playlistService.getFilesInPlaylist(playlistId, true);
for (Integer mediaFileId : mediaFileIds) {
MediaFile file = mediaFileService.getMediaFile(mediaFileId);
if (file != null) {
files.add(file);
}
}
playlistService.setFilesInPlaylist(playlistId, files);
}
use of org.libresonic.player.domain.MediaFile in project libresonic by Libresonic.
the class PlaylistService method down.
public PlaylistInfo down(int id, int index) {
List<MediaFile> files = playlistService.getFilesInPlaylist(id, true);
if (index < files.size() - 1) {
MediaFile file = files.remove(index);
files.add(index + 1, file);
playlistService.setFilesInPlaylist(id, files);
}
return getPlaylist(id);
}
Aggregations