mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 14:25:02 -05:00
* allow AcoustID override mode that'll only use acoustid data as backup but prefer id3 tag if possible
This commit is contained in:
parent
768fcd3075
commit
f3e5ab574b
@ -7,13 +7,16 @@ import static net.sourceforge.tuned.FileUtilities.*;
|
|||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
import net.sourceforge.filebot.web.AudioTrack;
|
import net.sourceforge.filebot.web.AudioTrack;
|
||||||
|
import net.sourceforge.filebot.web.ID3Lookup;
|
||||||
import net.sourceforge.filebot.web.MusicIdentificationService;
|
import net.sourceforge.filebot.web.MusicIdentificationService;
|
||||||
import net.sourceforge.filebot.web.SortOrder;
|
import net.sourceforge.filebot.web.SortOrder;
|
||||||
|
|
||||||
@ -31,11 +34,28 @@ class AudioFingerprintMatcher implements AutoCompleteMatcher {
|
|||||||
@Override
|
@Override
|
||||||
public List<Match<File, ?>> match(List<File> files, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception {
|
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<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||||
|
List<File> audioFiles = filter(files, AUDIO_FILES);
|
||||||
|
|
||||||
// check audio files against acoustid
|
// check audio files against acoustid
|
||||||
for (Entry<File, AudioTrack> it : service.lookup(filter(files, AUDIO_FILES)).entrySet()) {
|
for (Entry<File, AudioTrack> it : service.lookup(audioFiles).entrySet()) {
|
||||||
if (it.getKey().exists() && it.getValue() != null) {
|
if (it.getKey().exists() && it.getValue() != null) {
|
||||||
matches.add(new Match<File, AudioTrack>(it.getKey(), it.getValue().clone()));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user