* set "fpcalc" executable via system property net.sourceforge.filebot.AcoustID.fpcalc
This commit is contained in:
parent
8144a4b2e0
commit
19f69c9fbc
|
@ -216,10 +216,13 @@
|
|||
<copy tofile="${dir.dist}/appbundle/FileBot.jar" file="${path.fatjar}" />
|
||||
|
||||
<!-- build app bundle folder and add native libs -->
|
||||
<jarbundler dir="${dir.dist}" name="${title}" version="${version}" build="${svn.revision}" icon="${dir.installer}/appbundle/icon.icns" bundleid="net.sourceforge.filebot" jar="${dir.dist}/appbundle/FileBot.jar" stubfile="${dir.installer}/appbundle/JavaApplicationStub" workingdirectory="$APP_PACKAGE/Contents/Resources/Java" mainclass="net.sourceforge.filebot.Main" jvmversion="1.6+">
|
||||
<jarbundler dir="${dir.dist}" name="${title}" version="${version}" build="${svn.revision}" icon="${dir.installer}/appbundle/icon.icns" bundleid="net.sourceforge.filebot" jar="${dir.dist}/appbundle/FileBot.jar" stubfile="${dir.installer}/appbundle/JavaApplicationStub" workingdirectory="$JAVAROOT" mainclass="net.sourceforge.filebot.Main" jvmversion="1.6+">
|
||||
<javaproperty name="application.deployment" value="app" />
|
||||
<javaproperty name="unixfs" value="false" />
|
||||
<javaproperty name="useExtendedFileAttributes" value="true" />
|
||||
<javaproperty name="net.sourceforge.filebot.AcoustID.fpcalc" value="$JAVAROOT/fpcalc" />
|
||||
<javaproperty name="jna.library.path" value="$JAVAROOT" />
|
||||
<javaproperty name="java.library.path" value="$JAVAROOT" />
|
||||
<javaproperty name="java.net.useSystemProxies" value="true" />
|
||||
<javaproperty name="sun.net.client.defaultConnectTimeout" value="10000" />
|
||||
<javaproperty name="sun.net.client.defaultReadTimeout" value="60000" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||
dir_bin="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
BIN_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
dir_app=$dir_bin/../Resources/Java
|
||||
java -Djava.awt.headless=true -Dunixfs=false -DuseExtendedFileAttributes=true -Djava.net.useSystemProxies=true -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=app "-Djna.library.path=$dir_app" "-Djava.library.path=$dir_app" -jar "$dir_app/FileBot.jar" "$@"
|
||||
JAVAROOT=$BIN_DIR/../Resources/Java
|
||||
java -Djava.awt.headless=true -Dunixfs=false -DuseExtendedFileAttributes=true -Djava.net.useSystemProxies=true -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=app "-Djna.library.path=$JAVAROOT" "-Djava.library.path=$JAVAROOT" "-Dnet.sourceforge.filebot.AcoustID.fpcalc=$JAVAROOT/fpcalc" -jar "$JAVAROOT/FileBot.jar" "$@"
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
java -Dunixfs=false -DuseGVFS=false -DuseExtendedFileAttributes=false -Djava.net.useSystemProxies=false -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=deb -Dapplication.analytics=true -Dapplication.warmup=true -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -jar /usr/share/filebot/FileBot.jar "$@"
|
||||
java -Dunixfs=false -DuseGVFS=false -DuseExtendedFileAttributes=false -Djava.net.useSystemProxies=false -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=deb -Dapplication.analytics=true -Dapplication.warmup=true -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dnet.sourceforge.filebot.AcoustID.fpcalc=fpcalc -jar /usr/share/filebot/FileBot.jar "$@"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/sh
|
||||
java -Dunixfs=false -DuseExtendedFileAttributes=false -Dfile.encoding=UTF-8 -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=ipkg -Dapplication.analytics=true -Duser.home=/opt/usr/share/filebot/data -Dapplication.dir=/opt/usr/share/filebot/data -Djava.io.tmpdir=/opt/usr/share/filebot/data/temp -Djna.library.path=/opt/usr/share/filebot -Djava.library.path=/opt/usr/share/filebot -jar /opt/usr/share/filebot/FileBot.jar "$@"
|
||||
java -Dunixfs=false -DuseExtendedFileAttributes=false -Dfile.encoding=UTF-8 -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=ipkg -Dapplication.analytics=true -Duser.home=/opt/usr/share/filebot/data -Dapplication.dir=/opt/usr/share/filebot/data -Djava.io.tmpdir=/opt/usr/share/filebot/data/temp -Djna.library.path=/opt/usr/share/filebot -Djava.library.path=/opt/usr/share/filebot -Dnet.sourceforge.filebot.AcoustID.fpcalc=fpcalc -jar /opt/usr/share/filebot/FileBot.jar "$@"
|
|
@ -16,3 +16,6 @@
|
|||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
-Djava.library.path="%EXEDIR%"
|
||||
|
||||
# look for fpcalc here
|
||||
-Dnet.sourceforge.filebot.AcoustID.fpcalc="%EXEDIR%\fpcalc.exe"
|
||||
|
|
|
@ -20,3 +20,6 @@
|
|||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
-Djava.library.path="%EXEDIR%"
|
||||
|
||||
# look for fpcalc here
|
||||
-Dnet.sourceforge.filebot.AcoustID.fpcalc="%EXEDIR%\fpcalc.exe"
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
-Djna.library.path="%EXEDIR%"
|
||||
-Djava.library.path="%EXEDIR%"
|
||||
|
||||
# look for fpcalc here
|
||||
-Dnet.sourceforge.filebot.AcoustID.fpcalc="%EXEDIR%\fpcalc.exe"
|
||||
|
||||
# force english locale
|
||||
-Dfile.encoding=UTF-8
|
||||
-Duser.country=US
|
||||
|
|
|
@ -19,12 +19,15 @@
|
|||
-DuseExtendedFileAttributes=false
|
||||
|
||||
# put all temporary files here
|
||||
-Djava.io.tmpdir="%EXEDIR%/temp"
|
||||
-Djava.io.tmpdir="%EXEDIR%\temp"
|
||||
|
||||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
-Djava.library.path="%EXEDIR%"
|
||||
|
||||
# look for fpcalc here
|
||||
-Dnet.sourceforge.filebot.AcoustID.fpcalc="%EXEDIR%\fpcalc.exe"
|
||||
|
||||
# store preferences to text file
|
||||
-Djava.util.prefs.PreferencesFactory=net.sourceforge.tuned.prefs.FilePreferencesFactory
|
||||
-Dnet.sourceforge.tuned.prefs.file="%EXEDIR%/prefs.properties"
|
||||
-Dnet.sourceforge.tuned.prefs.file="%EXEDIR%\prefs.properties"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
java -Dunixfs=false -DuseGVFS=true -DuseExtendedFileAttributes=true -Djava.net.useSystemProxies=true -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.update=skip -Dapplication.deployment=ppa -Dapplication.analytics=false -Dapplication.warmup=true -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/opt/filebot -Djava.library.path=/opt/filebot -jar /opt/filebot/FileBot.jar "$@"
|
||||
java -Dunixfs=false -DuseGVFS=true -DuseExtendedFileAttributes=true -Djava.net.useSystemProxies=true -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.update=skip -Dapplication.deployment=ppa -Dapplication.analytics=false -Dapplication.warmup=true -Dapplication.dir=$HOME/.filebot -Djava.io.tmpdir=$HOME/.filebot/temp -Djna.library.path=/opt/filebot -Djava.library.path=/opt/filebot -Dnet.sourceforge.filebot.AcoustID.fpcalc=fpcalc -jar /opt/filebot/FileBot.jar "$@"
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.sourceforge.filebot.web.WebRequest.*;
|
||||
import static net.sourceforge.tuned.FileUtilities.*;
|
||||
|
@ -29,70 +27,62 @@ import net.sourceforge.filebot.ResourceManager;
|
|||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
|
||||
public class AcoustID implements MusicIdentificationService {
|
||||
|
||||
|
||||
private static final FloodLimit REQUEST_LIMIT = new FloodLimit(3, 1, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
private String apikey;
|
||||
|
||||
|
||||
|
||||
public AcoustID(String apikey) {
|
||||
this.apikey = apikey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AcoustID";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getIcon("search.acoustid");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<File, AudioTrack> lookup(Iterable<File> files) throws Exception {
|
||||
Map<File, AudioTrack> results = new LinkedHashMap<File, AudioTrack>();
|
||||
|
||||
|
||||
for (Map<String, String> fp : fpcalc(files)) {
|
||||
results.put(new File(fp.get("FILE")), parse(lookup(fp.get("DURATION"), fp.get("FINGERPRINT"))));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String lookup(File file) throws Exception {
|
||||
Map<String, String> fp = fpcalc(singleton(file)).get(0);
|
||||
return lookup(fp.get("DURATION"), fp.get("FINGERPRINT"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String lookup(String duration, String fingerprint) throws IOException, InterruptedException, ParseException {
|
||||
// http://api.acoustid.org/v2/lookup?client=8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80I-_RoHxx_UHeBxrJw62Q34Kd7MEfpCcu6BLeB1ePw6OO4sOF_sHhmB504WWDZiEu8sKPpkcfCT9xfej0o0lr4T5yNJeOvjmu40w-TDmqHXmYgfFhFy_M7tD1o0cO_B2ms2j-ACEEQgQgAIwzTgAGmBIKIImNQAABwgQATAlhDGCCEIGIIM4BaBgwQBogEBIOESEIA8ARI5xAhxEFmAGAMCKAURKQQpQzRAAkCCBQEAKkQYIYIQQxCixCDADCABMAE0gpJIgyxhEDiCKCCIGAEIgJIQByAhFgGACCACMRQEyBAoxQiHiCBCFOECQFAIgAABR2QAgFjCDMA0AUMIoAIMChQghChASGEGeYEAIAIhgBSErnJPPEGWYAMgw05AhiiGHiBBBGGSCQcQgwRYJwhDDhgCSCSSEIQYwILoyAjAIigBFEUQK8gAYAQ5BCAAjkjCCAEEMZAUQAZQCjCCkpCgFMCCiIcVIAZZgilAQAiSHQECOcQAQIc4QClAHAjDDGkAGAMUoBgyhihgEChFCAAWEIEYwIJYwViAAlHCBIGEIEAEIQAoBwwgwiEBAEEEOoEwBY4wRwxAhBgAcKAESIQAwwIowRFhoBhAE
|
||||
URL url = new URL("http://api.acoustid.org/v2/lookup?client=" + apikey + "&meta=recordings+releasegroups+releases+tracks+compress&duration=" + duration + "&fingerprint=" + fingerprint);
|
||||
|
||||
|
||||
Cache cache = Cache.getCache("web-datasource");
|
||||
String response = cache.get(url, String.class);
|
||||
if (response != null) {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
// respect rate limit
|
||||
REQUEST_LIMIT.acquirePermit();
|
||||
response = readAll(getReader(url.openConnection()));
|
||||
cache.put(url, response);
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AudioTrack parse(String json) throws IOException, InterruptedException, ParseException {
|
||||
Map<?, ?> data = (Map<?, ?>) new JSONParser().parse(json);
|
||||
|
||||
|
||||
if (!data.get("status").equals("ok")) {
|
||||
throw new IOException("acoustid responded with error: " + data.get("status"));
|
||||
}
|
||||
|
@ -100,15 +90,15 @@ public class AcoustID implements MusicIdentificationService {
|
|||
for (Object result : (List<?>) data.get("results")) {
|
||||
try {
|
||||
Map<?, ?> recording = (Map<?, ?>) ((List<?>) ((Map<?, ?>) result).get("recordings")).get(0);
|
||||
|
||||
|
||||
String artist = (String) ((Map<?, ?>) ((List<?>) recording.get("artists")).get(0)).get("name");
|
||||
String title = (String) recording.get("title");
|
||||
|
||||
|
||||
AudioTrack audioTrack = new AudioTrack(artist, title, null);
|
||||
try {
|
||||
Map<?, ?> releaseGroup = (Map<?, ?>) ((List<?>) recording.get("releasegroups")).get(0);
|
||||
List<?> releases = (List<?>) releaseGroup.get("releases");
|
||||
|
||||
|
||||
for (Object it : releases) {
|
||||
try {
|
||||
AudioTrack thisRelease = new AudioTrack(artist, title, null);
|
||||
|
@ -119,19 +109,19 @@ public class AcoustID implements MusicIdentificationService {
|
|||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
if (thisRelease.albumReleaseDate == null || thisRelease.albumReleaseDate.getTimeStamp() >= (audioTrack.albumReleaseDate == null ? Long.MAX_VALUE : audioTrack.albumReleaseDate.getTimeStamp())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Map<?, ?> medium = (Map<?, ?>) ((List<?>) release.get("mediums")).get(0);
|
||||
thisRelease.mediumIndex = new Integer(medium.get("position").toString());
|
||||
thisRelease.mediumCount = new Integer(release.get("medium_count").toString());
|
||||
|
||||
|
||||
Map<?, ?> track = (Map<?, ?>) ((List<?>) medium.get("tracks")).get(0);
|
||||
thisRelease.trackIndex = new Integer(track.get("position").toString());
|
||||
thisRelease.trackCount = new Integer(medium.get("track_count").toString());
|
||||
|
||||
|
||||
try {
|
||||
thisRelease.album = release.get("title").toString();
|
||||
} catch (Exception e) {
|
||||
|
@ -143,7 +133,7 @@ public class AcoustID implements MusicIdentificationService {
|
|||
thisRelease.albumArtist = null;
|
||||
}
|
||||
thisRelease.trackTitle = (String) track.get("title");
|
||||
|
||||
|
||||
if (!"Various Artists".equalsIgnoreCase(thisRelease.albumArtist) && (thisRelease.album == null || !thisRelease.album.contains("Greatest Hits"))) {
|
||||
audioTrack = thisRelease;
|
||||
}
|
||||
|
@ -163,15 +153,17 @@ public class AcoustID implements MusicIdentificationService {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Map<String, String>> fpcalc(Iterable<File> files) throws IOException, InterruptedException {
|
||||
// use fpcalc executable path as specified by the cmdline or default to "fpcalc" and let the shell figure it out
|
||||
String fpcalc = System.getProperty("net.sourceforge.filebot.AcoustID.fpcalc", "fpcalc");
|
||||
|
||||
List<String> command = new ArrayList<String>();
|
||||
command.add("fpcalc");
|
||||
command.add(fpcalc);
|
||||
for (File f : files) {
|
||||
command.add(f.toString());
|
||||
}
|
||||
|
||||
|
||||
Process process = null;
|
||||
try {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||
|
@ -184,16 +176,16 @@ public class AcoustID implements MusicIdentificationService {
|
|||
} catch (Exception e) {
|
||||
throw new IOException("Failed to exec fpcalc: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
LinkedList<Map<String, String>> results = new LinkedList<Map<String, String>>();
|
||||
|
||||
|
||||
try {
|
||||
while (scanner.hasNextLine()) {
|
||||
String[] value = scanner.nextLine().split("=", 2);
|
||||
if (value.length != 2)
|
||||
continue;
|
||||
|
||||
|
||||
if (results.isEmpty() || results.getLast().containsKey(value[0])) {
|
||||
results.addLast(new HashMap<String, String>(3));
|
||||
}
|
||||
|
@ -202,11 +194,11 @@ public class AcoustID implements MusicIdentificationService {
|
|||
} finally {
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
|
||||
if (process.waitFor() != 0) {
|
||||
throw new IOException("Failed to exec fpcalc: Exit code " + process.exitValue());
|
||||
}
|
||||
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
// FileBot 2.62 (r993)
|
||||
println net.sourceforge.filebot.Settings.applicationIdentifier
|
||||
|
||||
// chromaprint-tools
|
||||
try {
|
||||
print 'chromaprint-tools: '
|
||||
def fpcalc = System.getProperty('net.sourceforge.filebot.AcoustID.fpcalc', 'fpcalc')
|
||||
def version = [fpcalc, '-version'].execute().text.trim() ?: 'fpcalc -version failed'
|
||||
println "$version ($fpcalc)"
|
||||
} catch(Throwable error) {
|
||||
println error
|
||||
}
|
||||
|
||||
// JNA Native: 3.5.0
|
||||
try {
|
||||
print 'JNA Native: '
|
||||
|
|
Loading…
Reference in New Issue