Search in sources :

Example 1 with File

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();
}
Also used : SqlParameter(org.springframework.jdbc.core.SqlParameter) BatchSqlUpdate(org.springframework.jdbc.object.BatchSqlUpdate) File(com.github.hakko.musiccabinet.domain.model.library.File)

Example 2 with File

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;
}
Also used : DirectoryContent(com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent) File(com.github.hakko.musiccabinet.domain.model.library.File)

Example 3 with File

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;
}
Also used : MetaData(com.github.hakko.musiccabinet.domain.model.library.MetaData) File(com.github.hakko.musiccabinet.domain.model.library.File) DateTime(org.joda.time.DateTime)

Example 4 with 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());
}
Also used : File(com.github.hakko.musiccabinet.domain.model.library.File) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 5 with File

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());
}
Also used : File(com.github.hakko.musiccabinet.domain.model.library.File) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

File (com.github.hakko.musiccabinet.domain.model.library.File)43 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)18 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)9 Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)8 UnittestLibraryUtil.submitFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.submitFile)7 DateTime (org.joda.time.DateTime)7 HashSet (java.util.HashSet)6 Before (org.junit.Before)6 DirectoryContent (com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent)5 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)5 Track (com.github.hakko.musiccabinet.domain.model.music.Track)5 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 MetaData (com.github.hakko.musiccabinet.domain.model.library.MetaData)3 SqlParameter (org.springframework.jdbc.core.SqlParameter)3 BatchSqlUpdate (org.springframework.jdbc.object.BatchSqlUpdate)3 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)2 LibraryPresenceDao (com.github.hakko.musiccabinet.dao.LibraryPresenceDao)1 LibraryStatistics (com.github.hakko.musiccabinet.domain.model.aggr.LibraryStatistics)1 PlaylistItem (com.github.hakko.musiccabinet.domain.model.aggr.PlaylistItem)1