Search in sources :

Example 36 with MusicFolder

use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.

the class MultiService method getSimilarArtists.

private List<SimilarArtist> getSimilarArtists(int mediaFileId, int limit) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    String username = securityService.getCurrentUsername(request);
    List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
    MediaFile artist = mediaFileService.getMediaFile(mediaFileId);
    List<MediaFile> similarArtists = lastFmService.getSimilarArtists(artist, limit, false, musicFolders);
    SimilarArtist[] result = new SimilarArtist[similarArtists.size()];
    for (int i = 0; i < result.length; i++) {
        MediaFile similarArtist = similarArtists.get(i);
        result[i] = new SimilarArtist(similarArtist.getId(), similarArtist.getName());
    }
    return Arrays.asList(result);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MediaFile(org.libresonic.player.domain.MediaFile) MusicFolder(org.libresonic.player.domain.MusicFolder)

Example 37 with MusicFolder

use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.

the class MetaDataParser method isRoot.

private boolean isRoot(File file) {
    SettingsService settings = ServiceLocator.getSettingsService();
    List<MusicFolder> folders = settings.getAllMusicFolders(false, true);
    for (MusicFolder folder : folders) {
        if (file.equals(folder.getPath())) {
            return true;
        }
    }
    return false;
}
Also used : SettingsService(org.libresonic.player.service.SettingsService) MusicFolder(org.libresonic.player.domain.MusicFolder)

Aggregations

MusicFolder (org.libresonic.player.domain.MusicFolder)37 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 HttpServletResponse (javax.servlet.http.HttpServletResponse)21 Artist (org.libresonic.player.domain.Artist)7 File (java.io.File)6 org.libresonic.restapi (org.libresonic.restapi)6 Date (java.util.Date)5 MediaFile (org.libresonic.player.domain.MediaFile)5 User (org.libresonic.player.domain.User)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SearchResult (org.libresonic.player.domain.SearchResult)3 Share (org.libresonic.player.domain.Share)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 FileOutputStream (java.io.FileOutputStream)1 DateFormat (java.text.DateFormat)1 HashMap (java.util.HashMap)1 MusicFolderSettingsCommand (org.libresonic.player.command.MusicFolderSettingsCommand)1 Player (org.libresonic.player.domain.Player)1