From e4c5db4c208e2334c126be27e088ee77ba9f10fa Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 26 Feb 2013 11:15:15 +0000 Subject: [PATCH] * fix AcoustID Json response processing * show donation reminder to 1/1000 users --- source/net/sourceforge/filebot/Main.java | 3 ++- source/net/sourceforge/filebot/web/AcoustID.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index 49b9dd71..914437a2 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -225,7 +225,7 @@ public class Main { int donateStep = 10000; int usage = history.totalSize(); - if (usage / donateStep > donateLv || new Random().nextInt(donateStep) == 777) { + if (usage / donateStep > donateLv || new Random().nextInt(1000) == 777) { persistentDonateLv.setValue(String.valueOf(Math.max(donateLv + 1, usage / donateStep))); String message = String.format(Locale.ROOT, "

Thank you for using FileBot!


It has taken many nights to develop this application. If you enjoy using it,
please consider a donation to the author of this software. It will help to
make FileBot even better!

You've renamed %,d files.


", history.totalSize()); @@ -235,6 +235,7 @@ public class Main { if (pane.getValue() == actions[0]) { Desktop.getDesktop().browse(URI.create(getApplicationProperty("donate.url"))); } + Analytics.trackEvent("GUI", "Donate", "Lv " + donateLv, pane.getValue() == actions[0] ? 1 : 0); } } catch (Exception e) { Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.getMessage(), e); diff --git a/source/net/sourceforge/filebot/web/AcoustID.java b/source/net/sourceforge/filebot/web/AcoustID.java index 2f2daed9..ff3b2297 100644 --- a/source/net/sourceforge/filebot/web/AcoustID.java +++ b/source/net/sourceforge/filebot/web/AcoustID.java @@ -25,7 +25,8 @@ import javax.swing.Icon; import net.sourceforge.filebot.Cache; import net.sourceforge.filebot.ResourceManager; -import com.cedarsoftware.util.io.JsonReader; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; public class AcoustID implements MusicIdentificationService { @@ -63,7 +64,7 @@ public class AcoustID implements MusicIdentificationService { } - public AudioTrack lookup(String duration, String fingerprint) throws IOException, InterruptedException { + public AudioTrack lookup(String duration, String fingerprint) throws IOException, InterruptedException, ParseException { // http://api.acoustid.org/v2/lookup?client=8XaBELgH&meta=recordings+releasegroups+compress&duration=641&fingerprint=AQABz0qUkZK4oOfhL-CPc4e5C_wW2H2QH9uDL4cvoT8UNQ-eHtsE8cceeFJx-LiiHT-aPzhxoc-Opj_eI5d2hOFyMJRzfDk-QSsu7fBxqZDMHcfxPfDIoPWxv9C1o3yg44d_3Df2GJaUQeeR-cb2HfaPNsdxHj2PJnpwPMN3aPcEMzd-_MeB_Ej4D_CLP8ghHjkJv_jh_UDuQ8xnILwunPg6hF2R8HgzvLhxHVYP_ziJX0eKPnIE1UePMByDJyg7wz_6yELsB8n4oDmDa0Gv40hf6D3CE3_wH6HFaxCPUD9-hNeF5MfWEP3SCGym4-SxnXiGs0mRjEXD6fgl4LmKWrSChzzC33ge9PB3otyJMk-IVC6R8MTNwD9qKQ_CC8kPv4THzEGZS8GPI3x0iGVUxC1hRSizC5VzoamYDi-uR7iKPhGSI82PkiWeB_eHijvsaIWfBCWH5AjjCfVxZ1TQ3CvCTclGnEMfHbnZFA8pjD6KXwd__Cn-Y8e_I9cq6CR-4S9KLXqQcsxxoWh3eMxiHI6TIzyPv0M43YHz4yte-Cv-4D16Hv9F9C9SPUdyGtZRHV-OHEeeGD--BKcjVLOK_NCDXMfx44dzHEiOZ0Z44Rf6DH5R3uiPj4d_PKolJNyRJzyu4_CTD2WOvzjKH9GPb4cUP1Av9EuQd8fGCFee4JlRHi18xQh96NLxkCgfWFKOH6WGeoe4I3za4c5hTscTPEZTES1x8kE-9MQPjT8a8gh5fPgQZtqCFj9MDvp6fDx6NCd07bjx7MLR9AhtnFnQ70GjOcV0opmm4zpY3SOa7HiwdTtyHa6NC4e-HN-OfC5-OP_gLe2QDxfUCz_0w9l65HiPAz9-IaGOUA7-4MZ5CWFOlIfe4yUa6AiZGxf6w0fFxsjTOdC6Itbh4mGD63iPH9-RFy909XAMj7mC5_BvlDyO6kGTZKJxHUd4NDwuZUffw_5RMsde5CWkJAgXnDReNEaP6DTOQ65yaD88HoeX8fge-DSeHo9Qa8cTHc80I-_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); @@ -76,7 +77,7 @@ public class AcoustID implements MusicIdentificationService { REQUEST_LIMIT.acquirePermit(); String response = readAll(getReader(url.openConnection())); - Map data = JsonReader.jsonToMaps(response); + Map data = (Map) new JSONParser().parse(response); if (!data.get("status").equals("ok")) { throw new IOException("acoustid responded with error: " + data.get("status"));