From bd3652ff2dfb42506bc1e750d5f62d38b0b4d275 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 11 Jan 2013 07:05:11 +0000 Subject: [PATCH] * make music matching work properly and adjust build --- build.xml | 2 +- .../ui/rename/AudioFingerprintMatcher.java | 4 ++- .../net/sourceforge/filebot/web/AcoustID.java | 33 +++++++++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/build.xml b/build.xml index b469a125..762d2e2e 100644 --- a/build.xml +++ b/build.xml @@ -244,7 +244,7 @@ - + FileBot is the ultimate tool for renaming your movies, tv shows or anime and downloading subtitles. It's smart, streamlined for simplicity and just works. Plus there's a full-featured command-line interface for all sorts of automation. diff --git a/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java b/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java index a4e0279b..4f119739 100644 --- a/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java @@ -34,7 +34,9 @@ class AudioFingerprintMatcher implements AutoCompleteMatcher { // check audio files against acoustid for (Entry it : service.lookup(filter(files, AUDIO_FILES)).entrySet()) { - matches.add(new Match(it.getKey(), it.getValue())); + if (it.getKey().exists() && it.getValue() != null) { + matches.add(new Match(it.getKey(), it.getValue())); + } } return matches; diff --git a/source/net/sourceforge/filebot/web/AcoustID.java b/source/net/sourceforge/filebot/web/AcoustID.java index 590ebc92..7dd14ae7 100644 --- a/source/net/sourceforge/filebot/web/AcoustID.java +++ b/source/net/sourceforge/filebot/web/AcoustID.java @@ -75,19 +75,28 @@ public class AcoustID { if (!data.get("status").equals("ok")) { throw new IOException("acoustid responded with error: " + data.get("status")); } - - Map recording = (Map) ((List) ((Map) ((List) data.get("results")).get(0)).get("recordings")).get(0); - String artist = (String) ((Map) ((List) recording.get("artists")).get(0)).get("name"); - String title = (String) recording.get("title"); - String album = (String) ((Map) ((List) recording.get("releasegroups")).get(0)).get("title"); - audioTrack = new AudioTrack(artist, title, album); - - cache.put(url, audioTrack); - return audioTrack; + try { + Map recording = (Map) ((List) ((Map) ((List) data.get("results")).get(0)).get("recordings")).get(0); + String artist = (String) ((Map) ((List) recording.get("artists")).get(0)).get("name"); + String title = (String) recording.get("title"); + String album = null; + try { + album = (String) ((Map) ((List) recording.get("releasegroups")).get(0)).get("title"); + } catch (Exception e) { + // allow album to be null + } + + audioTrack = new AudioTrack(artist, title, album); + cache.put(url, audioTrack); + return audioTrack; + } catch (Exception e) { + // no results + return null; + } } - public List> fpcalc(Iterable files) throws IOException { + public List> fpcalc(Iterable files) throws IOException, InterruptedException { List command = new ArrayList(); command.add("fpcalc"); for (File f : files) { @@ -119,6 +128,10 @@ public class AcoustID { scanner.close(); } + if (process.waitFor() != 0) { + throw new IOException("Failed to exec fpcalc: Exit code " + process.exitValue()); + } + return results; } }