mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* try to grab more optional ID3 tags if available
This commit is contained in:
parent
bed1e7246f
commit
1c46ed1809
@ -604,7 +604,7 @@ public class MediaBindingBean {
|
||||
@Define("pn")
|
||||
public Integer getPartCount() {
|
||||
if (infoObject instanceof AudioTrack)
|
||||
return getMusic().getTrackCount();
|
||||
return getMusic().getTrackCount() != null ? getMusic().getTrackCount() : Integer.parseInt(getMediaInfo(StreamKind.General, 0, "Track/Position_Total"));
|
||||
if (infoObject instanceof MoviePart)
|
||||
return ((MoviePart) infoObject).getPartCount();
|
||||
|
||||
|
@ -4,6 +4,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
@ -33,13 +36,42 @@ public class ID3Lookup implements MusicIdentificationService {
|
||||
throw new IOException("MediaInfo failed to open file: " + f);
|
||||
}
|
||||
|
||||
try {
|
||||
String artist = mediaInfo.get(StreamKind.General, 0, "Performer");
|
||||
String title = mediaInfo.get(StreamKind.General, 0, "Title");
|
||||
String album = mediaInfo.get(StreamKind.General, 0, "Album");
|
||||
mediaInfo.close();
|
||||
|
||||
// extra info if available
|
||||
String albumArtist = null, trackTitle = null;
|
||||
Date albumReleaseDate = null;
|
||||
Integer mediumIndex = null, mediumCount = null, trackIndex = null, trackCount = null;
|
||||
|
||||
try {
|
||||
int year = new Scanner(mediaInfo.get(StreamKind.General, 0, "Recorded_Date")).useDelimiter("\\D+").nextInt();
|
||||
albumReleaseDate = new Date(year, 1, 1);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
trackIndex = Integer.parseInt(mediaInfo.get(StreamKind.General, 0, "Track/Position"));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
trackCount = Integer.parseInt(mediaInfo.get(StreamKind.General, 0, "Track/Position_Total"));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
if (artist.length() > 0 && title.length() > 0 && album.length() > 0) {
|
||||
info.put(f, new AudioTrack(artist, title, album));
|
||||
info.put(f, new AudioTrack(artist, title, album, albumArtist, trackTitle, albumReleaseDate, mediumIndex, mediumCount, trackIndex, trackCount));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(ID3Lookup.class.getName()).log(Level.WARNING, e.getMessage(), e);
|
||||
} finally {
|
||||
mediaInfo.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user