use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getStarred.
@RequestMapping(value = "/rest/getStarred", method = { RequestMethod.GET, RequestMethod.POST })
public void getStarred(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
Integer musicFolderId = getIntParameter(request, "musicFolderId");
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username, musicFolderId);
Starred result = new Starred();
for (MediaFile artist : mediaFileDao.getStarredDirectories(0, Integer.MAX_VALUE, username, musicFolders)) {
result.getArtist().add(createJaxbArtist(artist, username));
}
for (MediaFile album : mediaFileDao.getStarredAlbums(0, Integer.MAX_VALUE, username, musicFolders)) {
result.getAlbum().add(createJaxbChild(player, album, username));
}
for (MediaFile song : mediaFileDao.getStarredFiles(0, Integer.MAX_VALUE, username, musicFolders)) {
result.getSong().add(createJaxbChild(player, song, username));
}
Response res = createResponse();
res.setStarred(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method search3.
@RequestMapping(value = "/rest/search3", method = { RequestMethod.GET, RequestMethod.POST })
public void search3(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
Integer musicFolderId = getIntParameter(request, "musicFolderId");
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username, musicFolderId);
SearchResult3 searchResult = new SearchResult3();
String query = request.getParameter("query");
SearchCriteria criteria = new SearchCriteria();
criteria.setQuery(StringUtils.trimToEmpty(query));
criteria.setCount(getIntParameter(request, "artistCount", 20));
criteria.setOffset(getIntParameter(request, "artistOffset", 0));
SearchResult result = searchService.search(criteria, musicFolders, SearchService.IndexType.ARTIST_ID3);
for (Artist artist : result.getArtists()) {
searchResult.getArtist().add(createJaxbArtist(new ArtistID3(), artist, username));
}
criteria.setCount(getIntParameter(request, "albumCount", 20));
criteria.setOffset(getIntParameter(request, "albumOffset", 0));
result = searchService.search(criteria, musicFolders, SearchService.IndexType.ALBUM_ID3);
for (Album album : result.getAlbums()) {
searchResult.getAlbum().add(createJaxbAlbum(new AlbumID3(), album, username));
}
criteria.setCount(getIntParameter(request, "songCount", 20));
criteria.setOffset(getIntParameter(request, "songOffset", 0));
result = searchService.search(criteria, musicFolders, SearchService.IndexType.SONG);
for (MediaFile song : result.getMediaFiles()) {
searchResult.getSong().add(createJaxbChild(player, song, username));
}
Response res = createResponse();
res.setSearchResult3(searchResult);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getArtistInfo.
@RequestMapping(value = "/rest/getArtistInfo", method = { RequestMethod.GET, RequestMethod.POST })
public void getArtistInfo(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
int id = getRequiredIntParameter(request, "id");
int count = getIntParameter(request, "count", 20);
boolean includeNotPresent = ServletRequestUtils.getBooleanParameter(request, "includeNotPresent", false);
ArtistInfo result = new ArtistInfo();
MediaFile mediaFile = mediaFileService.getMediaFile(id);
if (mediaFile == null) {
error(request, response, ErrorCode.NOT_FOUND, "Media file not found.");
return;
}
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<MediaFile> similarArtists = lastFmService.getSimilarArtists(mediaFile, count, includeNotPresent, musicFolders);
for (MediaFile similarArtist : similarArtists) {
result.getSimilarArtist().add(createJaxbArtist(similarArtist, username));
}
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile);
if (artistBio != null) {
result.setBiography(artistBio.getBiography());
result.setMusicBrainzId(artistBio.getMusicBrainzId());
result.setLastFmUrl(artistBio.getLastFmUrl());
result.setSmallImageUrl(artistBio.getSmallImageUrl());
result.setMediumImageUrl(artistBio.getMediumImageUrl());
result.setLargeImageUrl(artistBio.getLargeImageUrl());
}
Response res = createResponse();
res.setArtistInfo(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getArtistInfo2.
@RequestMapping(value = "/rest/getArtistInfo2", method = { RequestMethod.GET, RequestMethod.POST })
public void getArtistInfo2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
int id = getRequiredIntParameter(request, "id");
int count = getIntParameter(request, "count", 20);
boolean includeNotPresent = ServletRequestUtils.getBooleanParameter(request, "includeNotPresent", false);
ArtistInfo2 result = new ArtistInfo2();
Artist artist = artistDao.getArtist(id);
if (artist == null) {
error(request, response, ErrorCode.NOT_FOUND, "Artist not found.");
return;
}
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<Artist> similarArtists = lastFmService.getSimilarArtists(artist, count, includeNotPresent, musicFolders);
for (Artist similarArtist : similarArtists) {
result.getSimilarArtist().add(createJaxbArtist(new ArtistID3(), similarArtist, username));
}
ArtistBio artistBio = lastFmService.getArtistBio(artist);
if (artistBio != null) {
result.setBiography(artistBio.getBiography());
result.setMusicBrainzId(artistBio.getMusicBrainzId());
result.setLastFmUrl(artistBio.getLastFmUrl());
result.setSmallImageUrl(artistBio.getSmallImageUrl());
result.setMediumImageUrl(artistBio.getMediumImageUrl());
result.setLargeImageUrl(artistBio.getLargeImageUrl());
}
Response res = createResponse();
res.setArtistInfo2(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getVideos.
@RequestMapping(value = "/rest/getVideos", method = { RequestMethod.GET, RequestMethod.POST })
public void getVideos(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
int size = getIntParameter(request, "size", Integer.MAX_VALUE);
int offset = getIntParameter(request, "offset", 0);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
Videos result = new Videos();
for (MediaFile mediaFile : mediaFileDao.getVideos(size, offset, musicFolders)) {
result.getVideo().add(createJaxbChild(player, mediaFile, username));
}
Response res = createResponse();
res.setVideos(result);
jaxbWriter.writeResponse(request, response, res);
}
Aggregations