mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
Support ID3 with AcoustID fallback
This commit is contained in:
parent
b71b16f60b
commit
451424153f
@ -6,9 +6,10 @@ import static net.filebot.util.FileUtilities.*;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import net.filebot.similarity.Match;
|
import net.filebot.similarity.Match;
|
||||||
import net.filebot.web.AudioTrack;
|
import net.filebot.web.AudioTrack;
|
||||||
@ -17,25 +18,25 @@ import net.filebot.web.SortOrder;
|
|||||||
|
|
||||||
class AudioFingerprintMatcher implements AutoCompleteMatcher {
|
class AudioFingerprintMatcher implements AutoCompleteMatcher {
|
||||||
|
|
||||||
private MusicIdentificationService service;
|
private MusicIdentificationService[] services;
|
||||||
|
|
||||||
public AudioFingerprintMatcher(MusicIdentificationService service) {
|
public AudioFingerprintMatcher(MusicIdentificationService... services) {
|
||||||
this.service = service;
|
this.services = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Match<File, ?>> match(List<File> files, boolean strict, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception {
|
public List<Match<File, ?>> match(Collection<File> files, boolean strict, 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, VIDEO_FILES);
|
LinkedHashSet<File> remaining = new LinkedHashSet<File>(filter(files, AUDIO_FILES, VIDEO_FILES));
|
||||||
|
|
||||||
// check audio files against AcoustID
|
// check audio files against all services
|
||||||
if (audioFiles.size() > 0) {
|
for (int i = 0; i < services.length && remaining.size() > 0; i++) {
|
||||||
for (Entry<File, AudioTrack> it : service.lookup(audioFiles).entrySet()) {
|
services[i].lookup(remaining).forEach((k, v) -> {
|
||||||
if (it.getKey().exists() && it.getValue() != null) {
|
if (v != null) {
|
||||||
AudioTrack track = it.getValue().clone();
|
matches.add(new Match<File, AudioTrack>(k, v.clone()));
|
||||||
matches.add(new Match<File, AudioTrack>(it.getKey(), track));
|
remaining.remove(k);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
|
Loading…
Reference in New Issue
Block a user