use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MediaScannerServiceTestCase method testSpecialCharactersInFilename.
@Test
public void testSpecialCharactersInFilename() throws Exception {
Resource resource = resourceLoader.getResource("MEDIAS/piano.mp3");
String directoryName = "Muff1nman’s /Music";
String fileName = "Muff1nman’s/Piano.mp3";
File artistDir = temporaryFolder.newFolder(directoryName);
File musicFile = artistDir.toPath().resolve(fileName).toFile();
IOUtils.copy(resource.getInputStream(), new FileOutputStream(musicFile));
MusicFolder musicFolder = new MusicFolder(1, temporaryFolder.getRoot(), "Music", true, new Date());
musicFolderDao.createMusicFolder(musicFolder);
settingsService.clearMusicFolderCache();
TestCaseUtils.execScan(mediaScannerService);
MediaFile mediaFile = mediaFileService.getMediaFile(musicFile);
assertEquals(mediaFile.getFile().toString(), musicFile.toString());
System.out.println(mediaFile.getFile().getPath());
assertNotNull(mediaFile);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MusicFolderDaoTestCase method testUpdateMusicFolder.
@Test
public void testUpdateMusicFolder() {
MusicFolder musicFolder = new MusicFolder(new File("path"), "name", true, new Date());
musicFolderDao.createMusicFolder(musicFolder);
musicFolder = musicFolderDao.getAllMusicFolders().get(0);
musicFolder.setPath(new File("newPath"));
musicFolder.setName("newName");
musicFolder.setEnabled(false);
musicFolder.setChanged(new Date(234234L));
musicFolderDao.updateMusicFolder(musicFolder);
MusicFolder newMusicFolder = musicFolderDao.getAllMusicFolders().get(0);
assertMusicFolderEquals(musicFolder, newMusicFolder);
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MusicFolderTestData method getTestMusicFolders.
public static List<MusicFolder> getTestMusicFolders() {
List<MusicFolder> liste = new ArrayList<>();
File musicDir = new File(MusicFolderTestData.resolveMusicFolderPath());
MusicFolder musicFolder = new MusicFolder(1, musicDir, "Music", true, new Date());
liste.add(musicFolder);
File music2Dir = new File(MusicFolderTestData.resolveMusic2FolderPath());
MusicFolder musicFolder2 = new MusicFolder(2, music2Dir, "Music2", true, new Date());
liste.add(musicFolder2);
return liste;
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class MoreController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
String uploadDirectory = null;
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername());
if (musicFolders.size() > 0) {
uploadDirectory = new File(musicFolders.get(0).getPath(), "Incoming").getPath();
}
StringBuilder jamstashUrl = new StringBuilder("http://jamstash.com/#/settings?u=" + StringUtil.urlEncode(user.getUsername()) + "&url=");
jamstashUrl.append(StringUtil.urlEncode(NetworkService.getBaseUrl(request)));
Player player = playerService.getPlayer(request, response);
ModelAndView result = new ModelAndView();
result.addObject("model", map);
map.put("user", user);
map.put("uploadDirectory", uploadDirectory);
map.put("genres", mediaFileService.getGenres(false));
map.put("currentYear", Calendar.getInstance().get(Calendar.YEAR));
map.put("musicFolders", musicFolders);
map.put("clientSidePlaylist", player.isExternalWithPlaylist() || player.isWeb());
map.put("brand", settingsService.getBrand());
map.put("jamstashUrl", jamstashUrl);
return result;
}
use of org.libresonic.player.domain.MusicFolder in project libresonic by Libresonic.
the class RESTController method getArtists.
@RequestMapping(value = "/rest/getArtists", method = { RequestMethod.GET, RequestMethod.POST })
public void getArtists(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
String username = securityService.getCurrentUsername(request);
ArtistsID3 result = new ArtistsID3();
result.setIgnoredArticles(settingsService.getIgnoredArticles());
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
List<Artist> artists = artistDao.getAlphabetialArtists(0, Integer.MAX_VALUE, musicFolders);
SortedMap<MusicIndex, List<MusicIndex.SortableArtistWithArtist>> indexedArtists = musicIndexService.getIndexedArtists(artists);
for (Map.Entry<MusicIndex, List<MusicIndex.SortableArtistWithArtist>> entry : indexedArtists.entrySet()) {
IndexID3 index = new IndexID3();
result.getIndex().add(index);
index.setName(entry.getKey().getIndex());
for (MusicIndex.SortableArtistWithArtist sortableArtist : entry.getValue()) {
index.getArtist().add(createJaxbArtist(new ArtistID3(), sortableArtist.getArtist(), username));
}
}
Response res = createResponse();
res.setArtists(result);
jaxbWriter.writeResponse(request, response, res);
}
Aggregations