* new fpcalc seems to work with video files, so we magically get music video support !! :D

This commit is contained in:
Reinhard Pointner 2013-10-08 17:32:12 +00:00
parent 2cb532a1fb
commit 9e07634b79
3 changed files with 25 additions and 28 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot.ui.rename;
import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.tuned.FileUtilities.*;
@ -20,46 +18,45 @@ import net.sourceforge.filebot.web.ID3Lookup;
import net.sourceforge.filebot.web.MusicIdentificationService;
import net.sourceforge.filebot.web.SortOrder;
class AudioFingerprintMatcher implements AutoCompleteMatcher {
private MusicIdentificationService service;
public AudioFingerprintMatcher(MusicIdentificationService service) {
this.service = service;
}
@Override
public List<Match<File, ?>> match(List<File> files, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception {
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
List<File> audioFiles = filter(files, AUDIO_FILES);
List<File> audioFiles = filter(files, AUDIO_FILES, VIDEO_FILES);
// check audio files against acoustid
for (Entry<File, AudioTrack> it : service.lookup(audioFiles).entrySet()) {
if (it.getKey().exists() && it.getValue() != null) {
AudioTrack track = it.getValue().clone();
// use AcoustID as default but prefer with ID3 data if available
if (!autodetection) {
AudioTrack id3 = new ID3Lookup().lookup(Collections.singleton(it.getKey())).get(it.getKey());
for (Field field : AudioTrack.class.getDeclaredFields()) {
if (!field.isAccessible()) {
field.setAccessible(true);
}
Object id3value = field.get(id3);
if (id3value != null && !id3value.toString().isEmpty()) {
field.set(track, id3value);
if (audioFiles.size() > 0) {
for (Entry<File, AudioTrack> it : service.lookup(audioFiles).entrySet()) {
if (it.getKey().exists() && it.getValue() != null) {
AudioTrack track = it.getValue().clone();
// use AcoustID as default but prefer with ID3 data if available
if (!autodetection) {
AudioTrack id3 = new ID3Lookup().lookup(Collections.singleton(it.getKey())).get(it.getKey());
for (Field field : AudioTrack.class.getDeclaredFields()) {
if (!field.isAccessible()) {
field.setAccessible(true);
}
Object id3value = field.get(id3);
if (id3value != null && !id3value.toString().isEmpty()) {
field.set(track, id3value);
}
}
}
matches.add(new Match<File, AudioTrack>(it.getKey(), track));
}
matches.add(new Match<File, AudioTrack>(it.getKey(), track));
}
}
return matches;
}
}