use of com.github.hakko.musiccabinet.domain.model.library.File in project musiccabinet by hakko.
the class JdbcLibraryDeletionDao method deleteFiles.
@Override
public void deleteFiles(String directory, Set<File> files) {
String sql = "insert into library.file_delete (path, filename) values (?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.declareParameter(new SqlParameter("path", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("filename", Types.VARCHAR));
for (File file : files) {
batchUpdate.update(new Object[] { file.getDirectory(), file.getFilename() });
}
batchUpdate.flush();
}
use of com.github.hakko.musiccabinet.domain.model.library.File in project musiccabinet by hakko.
the class LibraryScanner method visitFile.
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
DirectoryContent directoryContent = map.get(file.getParent());
if (attr.size() > Integer.MAX_VALUE) {
LOG.warn(file.getFileName() + " has actual file size " + attr.size());
}
directoryContent.getFiles().add(new File(file, attr));
return CONTINUE;
}
use of com.github.hakko.musiccabinet.domain.model.library.File in project musiccabinet by hakko.
the class UnittestLibraryUtil method getFile.
public static File getFile() {
File file = new File("/unittest", "/unittest/file" + counter++ + ".ogg", new DateTime(), 0);
MetaData md = new MetaData();
md.setArtist("Unittest Artist");
md.setAlbum("Unittest Album " + counter);
md.setTitle("Unittest Title " + counter);
md.setBitrate((short) 144);
md.setVbr(false);
md.setDuration((short) 90);
md.setYear((short) 1900);
md.setMediaType(Mediatype.OGG);
file.setMetaData(md);
return file;
}
use of com.github.hakko.musiccabinet.domain.model.library.File in project musiccabinet by hakko.
the class AudioTagServiceTest method prefersId3V2Tags.
/*
* File id3v1+2.mp3 has different id3v1 and id3v2 tags. Assert v2 takes priority.
*/
@Test
public void prefersId3V2Tags() throws Exception {
java.io.File musicFile = new java.io.File(Thread.currentThread().getContextClassLoader().getResource("library/id3v1+2.mp3").toURI());
Assert.assertTrue(musicFile.exists());
Assert.assertTrue(musicFile.canRead());
File fileHandle = new File(musicFile.getParent(), musicFile.getName(), new DateTime(), 5717);
audioTagService.updateMetadata(fileHandle);
Assert.assertEquals("V2 Title", fileHandle.getMetadata().getTitle());
Assert.assertEquals("V2 Album", fileHandle.getMetadata().getAlbum());
Assert.assertEquals("V2 Artist", fileHandle.getMetadata().getArtist());
}
use of com.github.hakko.musiccabinet.domain.model.library.File in project musiccabinet by hakko.
the class AudioTagServiceTest method readsMp3V1TagAsISO88591.
@Test
public void readsMp3V1TagAsISO88591() throws Exception {
java.io.File musicFile = new java.io.File(Thread.currentThread().getContextClassLoader().getResource("library/id3v1.mp3").toURI());
Assert.assertTrue(musicFile.exists());
Assert.assertTrue(musicFile.canRead());
File fileHandle = new File(musicFile.getParent(), musicFile.getName(), new DateTime(), 5717);
audioTagService.updateMetadata(fileHandle);
Assert.assertEquals("Å", fileHandle.getMetadata().getTitle());
Assert.assertEquals("Ä", fileHandle.getMetadata().getAlbum());
Assert.assertEquals("Ö", fileHandle.getMetadata().getArtist());
}
Aggregations