Package com.github.hakko.musiccabinet.domain.model.library

Examples of com.github.hakko.musiccabinet.domain.model.library.MetaData


  private static int counter = 0;
 
  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;
  }
View Full Code Here


    return file;
  }
 
  public static File getFile(String artist, String album, String title) {
    File file = getFile();
    MetaData md = file.getMetadata();
    if (artist != null) md.setArtist(artist);
    if (album != null) md.setAlbum(album);
    if (title != null) md.setTitle(title);
    return file;
  }
View Full Code Here

    scrobbleService.setScrobbleClient(scrobbleClient);
   
    PlayCountDao playCountDao = mock(PlayCountDao.class);
    scrobbleService.setPlayCountDao(playCountDao);
   
    MetaData metaData1 = new MetaData();
    metaData1.setArtist("artist 1");
    metaData1.setArtistId(artist1Id);
    metaData1.setAlbum("album 1");
    metaData1.setAlbumId(album1Id);
    track1 = new Track(track1Id, "track 1", metaData1);
    track2 = new Track(track2Id, "track 2", metaData1);
    user1 = new LastFmUser(username1, sessionKey1);
    user2 = new LastFmUser(username2, sessionKey2);
  }
View Full Code Here

    int fileNr = 0;

    List<File> files = new ArrayList<>();
    for (short year : new short[]{2000, 2002, 2004, 2001, 2003}) {
      File file = new File(DIR, FILE + ++fileNr, parse(format("%d-01-01", year)), 0);
      MetaData md = new MetaData();
      md.setArtist("artist");
      md.setTitle("title " + fileNr);
      md.setAlbum("album " + fileNr);
      md.setYear(year);
      md.setMediaType(Mediatype.OGG);
      file.setMetaData(md);
      files.add(file);
    }
   
    libraryAdditionDao.addSubdirectories(null, set(DIR));
View Full Code Here

        + " offset ? limit ?";
    List<Track> albums = jdbcTemplate.query(sql,
        new Object[]{getNameQuery(userQuery), offset, limit}, new RowMapper<Track>() {
      @Override
      public Track mapRow(ResultSet rs, int rowNum) throws SQLException {
        MetaData metaData = new MetaData();
        metaData.setArtistId(rs.getInt(1));
        metaData.setArtist(rs.getString(2));
        metaData.setAlbumId(rs.getInt(3));
        metaData.setAlbum(rs.getString(4));
        return new Track(rs.getInt(5), rs.getString(6), metaData);
      }
    });

    return new NameSearchResult<>(albums, offset);
View Full Code Here

public class TrackWithMetadataRowMapper implements RowMapper<Track> {

  @Override
  public Track mapRow(ResultSet rs, int rowNum) throws SQLException {
    String trackName = rs.getString(1);
    MetaData md = new MetaData();
    md.setAlbum(rs.getString(2));
    md.setArtist(rs.getString(3));
    md.setAlbumArtist(rs.getString(4));
    md.setComposer(rs.getString(5));
    md.setTrackNr(rs.getShort(6));
    md.setTrackNrs(rs.getShort(7));
    md.setDiscNr(rs.getShort(8));
    md.setDiscNrs(rs.getShort(9));
    md.setYear(rs.getShort(10));
    md.setHasLyrics(rs.getBoolean(11));
    md.setBitrate(rs.getShort(12));
    md.setVbr(rs.getBoolean(13));
    md.setDuration(rs.getShort(14));
    md.setMediaType(Mediatype.values()[rs.getShort(15)]);
    md.setPath(rs.getString(16) + separatorChar + rs.getString(17));
    md.setSize(rs.getInt(18));
    md.setModified(rs.getTimestamp(19).getTime());
    int trackId = rs.getInt(20);
    md.setAlbumId(rs.getInt(21));
    md.setArtistId(rs.getInt(22));

    return new Track(trackId, trackName, md);
  }
View Full Code Here

    batch.declareParameter(new SqlParameter("lyrics", Types.VARCHAR));
    batch.declareParameter(new SqlParameter("coverart", Types.BOOLEAN));
    batch.declareParameter(new SqlParameter("artistsort_name", Types.VARCHAR));
    batch.declareParameter(new SqlParameter("albumartistsort_name", Types.VARCHAR));
    for (File file : files) {
      MetaData md = file.getMetadata();
      if (md != null) {
        batch.update(new Object[]{file.getDirectory(), file.getFilename(),
            md.getMediaType().getFilesuffix(), md.getBitrate(), md.isVbr(),
            md.getDuration(), md.getArtist(), md.getAlbumArtist(),
            md.getComposer(), md.getAlbum(), md.getTitle(), md.getTrackNr(),
            md.getTrackNrs(), md.getDiscNr(), md.getDiscNrs(), md.getYear(),
            md.getGenre(), md.getLyrics(), md.isCoverArtEmbedded(),
            md.getArtistSort(), md.getAlbumArtistSort()});
      }
    }
    batch.flush();
  }
View Full Code Here

    String extension = getExtension(file.getFilename()).toUpperCase();
    if (!ALLOWED_EXTENSIONS.contains(extension)) {
      return;
    }

    MetaData metaData = new MetaData();
    metaData.setMediaType(Mediatype.valueOf(extension));

    try {
      AudioFile audioFile = AudioFileIO.read(new java.io.File(
          file.getDirectory(), file.getFilename()));
     
      Tag tag = audioFile.getTag();
      if (tag != null) {
        metaData.setArtist(getTagField(tag, ARTIST));
        metaData.setArtistSort(getTagField(tag, ARTIST_SORT));
        metaData.setAlbumArtist(toAlbumArtist(tag));
        metaData.setAlbumArtistSort(getTagField(tag, ALBUM_ARTIST_SORT));
        metaData.setAlbum(toAlbum(getTagField(tag, ALBUM)));
        metaData.setTitle(getTagField(tag, TITLE));
        metaData.setYear(getTagField(tag, YEAR));
        metaData.setGenre(toGenre(getTagField(tag, GENRE)));
        metaData.setLyrics(getTagField(tag, LYRICS));
        metaData.setComposer(getTagField(tag, COMPOSER));
        metaData.setDiscNr(toFirstNumber(getTagField(tag, DISC_NO)));
        metaData.setDiscNrs(toShort(getTagField(tag, DISC_TOTAL)));
        metaData.setTrackNr(toFirstNumber(getTagField(tag, TRACK)));
        metaData.setTrackNrs(toShort(getTagField(tag, TRACK_TOTAL)));
        metaData.setCoverArtEmbedded(tag.getFirstArtwork() != null);
      }

      AudioHeader audioHeader = audioFile.getAudioHeader();
      if (audioHeader != null) {
        metaData.setVbr(audioHeader.isVariableBitRate());
        metaData.setBitrate((short) audioHeader.getBitRateAsNumber());
        metaData.setDuration((short) audioHeader.getTrackLength());
      }

      file.setMetaData(metaData);
     
    } catch (CannotReadException | IOException | TagException
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.domain.model.library.MetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.