* 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,9 +55,10 @@ 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>();
|
||||||
|
|
||||||
|
if (files.size() > 0) {
|
||||||
for (Map<String, String> fp : fpcalc(files)) {
|
for (Map<String, String> fp : fpcalc(files)) {
|
||||||
File file = new File(fp.get("FILE"));
|
File file = new File(fp.get("FILE"));
|
||||||
int duration = Integer.parseInt(fp.get("DURATION"));
|
int duration = Integer.parseInt(fp.get("DURATION"));
|
||||||
|
@ -69,6 +71,8 @@ public class AcoustIDClient implements MusicIdentificationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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