Merge remote-tracking branch 'origin/pr/1000'

master
Andrew DeMaria 6 years ago
commit 5671d11ab4
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 73
      airsonic-main/src/main/java/org/airsonic/player/service/metadata/JaudiotaggerParser.java

@ -28,12 +28,16 @@ import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.AudioHeader;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.id3.AbstractID3Tag;
import org.jaudiotagger.tag.id3.ID3v24Frames;
import org.jaudiotagger.tag.id3.ID3v24Tag;
import org.jaudiotagger.tag.images.Artwork;
import org.jaudiotagger.tag.reference.GenreTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.io.File;
import java.util.SortedSet;
@ -94,10 +98,71 @@ public class JaudiotaggerParser extends MetaDataParser {
metaData.setTrackNumber(parseTrackNumber(getTagField(tag, FieldKey.TRACK)));
metaData.setMusicBrainzReleaseId(getTagField(tag, FieldKey.MUSICBRAINZ_RELEASEID));
String songArtist = getTagField(tag, FieldKey.ARTIST);
String albumArtist = getTagField(tag, FieldKey.ALBUM_ARTIST);
metaData.setArtist(StringUtils.isBlank(songArtist) ? albumArtist : songArtist);
metaData.setAlbumArtist(StringUtils.isBlank(albumArtist) ? songArtist : albumArtist);
metaData.setArtist(getTagField(tag, FieldKey.ARTIST));
metaData.setAlbumArtist(getTagField(tag, FieldKey.ALBUM_ARTIST));
if (tag instanceof AbstractID3Tag && 0 < audioFile.getTag().getFieldCount()) {
AbstractID3Tag id3Tag = (AbstractID3Tag)tag;
if (ID3v24Tag.RELEASE == id3Tag.getRelease()
&& ID3v24Tag.MAJOR_VERSION == id3Tag.getMajorVersion()
&& ID3v24Tag.REVISION == id3Tag.getRevision()) {
audioFile.getTag().getFields().forEachRemaining(f -> {
switch (f.getId()) {
case ID3v24Frames.FRAME_ID_ALBUM:
if (StringUtils.isBlank(metaData.getAlbumName())) {
metaData.setAlbumName(f.toString());
}
break;
case ID3v24Frames.FRAME_ID_TITLE:
if (StringUtils.isBlank(metaData.getTitle())) {
metaData.setTitle(f.toString());
}
break;
case ID3v24Frames.FRAME_ID_YEAR:
if (ObjectUtils.isEmpty(metaData.getYear())) {
metaData.setYear(parseYear(f.toString()));
}
break;
case ID3v24Frames.FRAME_ID_GENRE:
if (StringUtils.isBlank(metaData.getGenre())) {
metaData.setGenre(mapGenre(f.toString()));
}
break;
case ID3v24Frames.FRAME_ID_SET:
if (ObjectUtils.isEmpty(metaData.getDiscNumber())) {
metaData.setDiscNumber(parseInteger(f.toString()));
}
break;
case ID3v24Frames.FRAME_ID_TRACK:
if (ObjectUtils.isEmpty(metaData.getTrackNumber())) {
metaData.setTrackNumber(parseTrackNumber(f.toString()));
}
break;
case ID3v24Frames.FRAME_ID_ARTIST:
if (StringUtils.isBlank(metaData.getArtist())) {
metaData.setArtist(f.toString());
}
break;
case ID3v24Frames.FRAME_ID_ACCOMPANIMENT:
if (StringUtils.isBlank(metaData.getAlbumArtist())) {
metaData.setAlbumArtist(f.toString());
}
break;
default:
break;
}
});
}
}
if (StringUtils.isBlank(metaData.getArtist())) {
metaData.setArtist(metaData.getAlbumArtist());
}
if (StringUtils.isBlank(metaData.getAlbumArtist())) {
metaData.setAlbumArtist(metaData.getArtist());
}
}
AudioHeader audioHeader = audioFile.getAudioHeader();

Loading…
Cancel
Save