* avoid odd behaviour when lookup is called with an empty list of files
This commit is contained in:
parent
2d4c573386
commit
693aa93224
|
@ -10,6 +10,7 @@ import java.lang.ProcessBuilder.Redirect;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -54,21 +55,24 @@ public class AcoustIDClient implements MusicIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<File, AudioTrack> lookup(Iterable<File> files) throws Exception {
|
public Map<File, AudioTrack> lookup(Collection<File> files) throws Exception {
|
||||||
Map<File, AudioTrack> results = new LinkedHashMap<File, AudioTrack>();
|
Map<File, AudioTrack> results = new LinkedHashMap<File, AudioTrack>();
|
||||||
|
|
||||||
for (Map<String, String> fp : fpcalc(files)) {
|
if (files.size() > 0) {
|
||||||
File file = new File(fp.get("FILE"));
|
for (Map<String, String> fp : fpcalc(files)) {
|
||||||
int duration = Integer.parseInt(fp.get("DURATION"));
|
File file = new File(fp.get("FILE"));
|
||||||
String fingerprint = fp.get("FINGERPRINT");
|
int duration = Integer.parseInt(fp.get("DURATION"));
|
||||||
|
String fingerprint = fp.get("FINGERPRINT");
|
||||||
|
|
||||||
if (duration > 10 && fingerprint != null) {
|
if (duration > 10 && fingerprint != null) {
|
||||||
String response = lookup(duration, fingerprint);
|
String response = lookup(duration, fingerprint);
|
||||||
if (response != null && response.length() > 0) {
|
if (response != null && response.length() > 0) {
|
||||||
results.put(file, parseResult(lookup(duration, fingerprint), duration));
|
results.put(file, parseResult(lookup(duration, fingerprint), duration));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +214,7 @@ public class AcoustIDClient implements MusicIdentificationService {
|
||||||
return System.getProperty("net.filebot.AcoustID.fpcalc", "fpcalc");
|
return System.getProperty("net.filebot.AcoustID.fpcalc", "fpcalc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> fpcalc(Iterable<File> files) throws IOException, InterruptedException {
|
public List<Map<String, String>> fpcalc(Collection<File> files) throws IOException, InterruptedException {
|
||||||
List<String> command = new ArrayList<String>();
|
List<String> command = new ArrayList<String>();
|
||||||
command.add(getChromaprintCommand());
|
command.add(getChromaprintCommand());
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.filebot.web;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
@ -27,7 +28,7 @@ public class ID3Lookup implements MusicIdentificationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<File, AudioTrack> lookup(Iterable<File> files) throws Exception {
|
public Map<File, AudioTrack> lookup(Collection<File> files) throws Exception {
|
||||||
Map<File, AudioTrack> info = new LinkedHashMap<File, AudioTrack>();
|
Map<File, AudioTrack> info = new LinkedHashMap<File, AudioTrack>();
|
||||||
|
|
||||||
MediaInfo mediaInfo = new MediaInfo();
|
MediaInfo mediaInfo = new MediaInfo();
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
|
|
||||||
package net.filebot.web;
|
package net.filebot.web;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
|
|
||||||
public interface MusicIdentificationService {
|
public interface MusicIdentificationService {
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
|
||||||
Icon getIcon();
|
Icon getIcon();
|
||||||
|
|
||||||
|
Map<File, AudioTrack> lookup(Collection<File> files) throws Exception;
|
||||||
Map<File, AudioTrack> lookup(Iterable<File> files) throws Exception;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue