use of com.mpatric.mp3agic.NotSupportedException in project selenium_java by sergueik.
the class DefaultId3vTagManager method fix.
@SneakyThrows
@Override
public File fix(File source) {
Mp3File mp3File = new Mp3File(source);
mp3File.removeCustomTag();
if (mp3File.hasId3v1Tag()) {
ID3v1 tag = mp3File.getId3v1Tag();
tag.setArtist(fixString(tag.getArtist()));
tag.setTitle(fixString(tag.getTitle()));
tag.setAlbum(fixString(tag.getAlbum()));
tag.setComment(fixString(tag.getComment()));
mp3File.setId3v1Tag(tag);
}
if (mp3File.hasId3v2Tag()) {
ID3v2 tag = mp3File.getId3v2Tag();
tag.setArtist(fixString(tag.getArtist()));
tag.setTitle(fixString(tag.getTitle()));
tag.setAlbum(fixString(tag.getAlbum()));
tag.setComment(fixString(tag.getComment()));
mp3File.setId3v2Tag(tag);
}
String filename = source.toString() + "_fixed.mp3";
try {
mp3File.save(filename);
} catch (NotSupportedException e) {
mp3File.removeId3v2Tag();
mp3File.save(filename);
}
return new File(filename);
}
Aggregations