From 7866e7f046c54b987330938b0c7dbb180c1e1cb0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 2 Aug 2014 10:12:20 +0000 Subject: [PATCH] + gzip all AcoustID requests and responses --- source/net/filebot/web/AcoustIDClient.java | 105 +++++++++++-------- source/net/filebot/web/WebRequest.java | 16 ++- test/net/filebot/web/AcoustIDClientTest.java | 50 +++++++++ test/net/filebot/web/WebTestSuite.java | 2 +- 4 files changed, 126 insertions(+), 47 deletions(-) create mode 100644 test/net/filebot/web/AcoustIDClientTest.java diff --git a/source/net/filebot/web/AcoustIDClient.java b/source/net/filebot/web/AcoustIDClient.java index 6185fc29..6fc7ef4f 100644 --- a/source/net/filebot/web/AcoustIDClient.java +++ b/source/net/filebot/web/AcoustIDClient.java @@ -1,7 +1,6 @@ package net.filebot.web; import static java.util.Collections.*; -import static net.filebot.util.FileUtilities.*; import static net.filebot.web.WebRequest.*; import java.io.File; @@ -9,6 +8,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.lang.ProcessBuilder.Redirect; import java.net.URL; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -68,20 +68,32 @@ public class AcoustIDClient implements MusicIdentificationService { } public String 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-hNe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GeYEAIAIhgBSErnJPPEGWYAMgw05AhiiGHiBBBGGSCQcQgwRYJwhDDhgCSCSSEIQYwILoyAjAIigBFEUQK8gAYAQ5BCAAjkjCCAEEMZAUQAZQCjCCkpCgFMCCiIcVIAZZgilAQAiSHQECOcQAQIc4QClAHAjDDGkAGAMUoBgyhihgEChFCAAWEIEYwIJYwViAAlHCBIGEIEAEIQAoBwwgwiEBAEEEOoEwBY4wRwxAhBgAcKAESIQAwwIowRFhoBhAE - URL url = new URL("http://api.acoustid.org/v2/lookup?client=" + apikey + "&meta=recordings+releasegroups+releases+tracks+compress&duration=" + duration + "&fingerprint=" + fingerprint); + Map postParam = new LinkedHashMap(); + postParam.put("duration", duration); + postParam.put("fingerprint", fingerprint); + String cacheKey = postParam.values().toString(); Cache cache = getCache(); - String response = cache.get(url, String.class); + String response = cache.get(cacheKey, String.class); if (response != null) { return response; } // respect rate limit REQUEST_LIMIT.acquirePermit(); - response = readAll(getReader(url.openConnection())); - cache.put(url, response); + // 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_eHijvsaIWfBCWH5AjjCfVxZ1TQ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UoBgyhihgEChFCAAWEIEYwIJYwViAAlHCBIGEIEAEIQAoBwwgwiEBAEEEOoEwBY4wRwxAhBgAcKAESIQAwwIowRFhoBhAE + URL url = new URL("http://api.acoustid.org/v2/lookup?client=" + apikey + "&meta=recordings+releasegroups+compress"); + + // enable compression for request and response + Map requestParam = new HashMap(); + requestParam.put("Content-Encoding", "gzip"); + requestParam.put("Accept-Encoding", "gzip"); + + // submit + response = Charset.forName("UTF-8").decode(post(url, postParam, requestParam)).toString(); + + cache.put(cacheKey, response); return response; } @@ -104,57 +116,60 @@ public class AcoustIDClient implements MusicIdentificationService { 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); - Map release = (Map) it; - Map date = (Map) release.get("date"); + if (releases != null) { + for (Object it : releases) { try { - thisRelease.albumReleaseDate = new SimpleDate(Integer.parseInt(date.get("year").toString()), Integer.parseInt(date.get("month").toString()), Integer.parseInt(date.get("day").toString())); + AudioTrack thisRelease = new AudioTrack(artist, title, null); + Map release = (Map) it; + Map date = (Map) release.get("date"); + try { + thisRelease.albumReleaseDate = new SimpleDate(Integer.parseInt(date.get("year").toString()), Integer.parseInt(date.get("month").toString()), Integer.parseInt(date.get("day").toString())); + } 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) { + thisRelease.album = (String) releaseGroup.get("title"); + } + try { + thisRelease.albumArtist = (String) ((Map) ((List) releaseGroup.get("artists")).get(0)).get("name"); + } catch (Exception e) { + 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; + } } catch (Exception e) { - // ignore + Logger.getLogger(AcoustIDClient.class.getName()).log(Level.WARNING, e.toString(), e); } - - 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) { - thisRelease.album = (String) releaseGroup.get("title"); - } - try { - thisRelease.albumArtist = (String) ((Map) ((List) releaseGroup.get("artists")).get(0)).get("name"); - } catch (Exception e) { - 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; - } - } catch (Exception e) { - e.printStackTrace(); } } } catch (Exception e) { - e.printStackTrace(); - // allow album to be null + Logger.getLogger(AcoustIDClient.class.getName()).log(Level.WARNING, e.toString(), e); } return audioTrack; } catch (Exception e) { + // ignore } } } catch (Exception e) { + // ignore } return null; } diff --git a/source/net/filebot/web/WebRequest.java b/source/net/filebot/web/WebRequest.java index 2f40aa22..b23324cb 100644 --- a/source/net/filebot/web/WebRequest.java +++ b/source/net/filebot/web/WebRequest.java @@ -1,5 +1,6 @@ package net.filebot.web; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -24,6 +25,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; @@ -174,7 +176,11 @@ public final class WebRequest { } public static ByteBuffer post(URL url, Map parameters, Map requestParameters) throws IOException { - return post(url, encodeParameters(parameters, true).getBytes("UTF-8"), "application/x-www-form-urlencoded", requestParameters); + byte[] postData = encodeParameters(parameters, true).getBytes("UTF-8"); + if (requestParameters != null && "gzip".equals(requestParameters.get("Content-Encoding"))) { + postData = gzip(postData); + } + return post(url, postData, "application/x-www-form-urlencoded", requestParameters); } public static ByteBuffer post(URL url, byte[] postData, String contentType, Map requestParameters) throws IOException { @@ -279,6 +285,14 @@ public final class WebRequest { } } + private static byte[] gzip(byte[] data) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(data.length); + GZIPOutputStream gzip = new GZIPOutputStream(out); + gzip.write(data); + gzip.close(); + return out.toByteArray(); + } + public static SSLSocketFactory createIgnoreCertificateSocketFactory() { // create a trust manager that does not validate certificate chains TrustManager trustAnyCertificate = new X509TrustManager() { diff --git a/test/net/filebot/web/AcoustIDClientTest.java b/test/net/filebot/web/AcoustIDClientTest.java new file mode 100644 index 00000000..a3a5a8e7 --- /dev/null +++ b/test/net/filebot/web/AcoustIDClientTest.java @@ -0,0 +1,50 @@ +package net.filebot.web; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import net.sf.ehcache.CacheManager; + +import org.json.simple.parser.ParseException; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +public class AcoustIDClientTest { + + AcoustIDClient client = new AcoustIDClient("0B3qZnQc"); + + @Test + public void lookup() throws Exception { + String duration = "357"; + String fingerprint = "AQADtIkSJWG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gAA65iQwAlADAMCMMgEAYQYR5wRABgFjQECAGaEYgAYpRjlQBDoCBCEWScEMIICIIkwgiCkEDFYQEOQIIIA4AhDTAAiAJACAGGEAE5AoIxCQBggKBDIQEeck0IwYoiBTAjEDCBACQBMQ4AgIoAQTCkjGGAACEUBQkw4IojAwAAOACGAIYAE8EoBRAACLhgRgCCIAIWIEAwQASBRBgBDBTBICQCgJIgojBRRDDBhgAAEGCAoFsAyRIwQhBDFHBQCGBKFIhQiBQClRAAlgENCAWYMIcwQQIgDAAACICHIKQMMIEQJQZUwRgGDgDAC"; + + String response = client.lookup(duration, fingerprint); + AudioTrack info = client.parse(response); + + assertEquals("Michael Jackson", info.getArtist()); + assertEquals("Thriller (instrumental)", info.getTitle()); + } + + @Test + @Ignore + public void lookupChinese() throws IOException, InterruptedException, ParseException { + String duration = "265"; + String fingerprint = "AQADtJmWRFJCRkGcHXceND_Oquhz1H_xvjg8D8mYIf5-fOpKVE81NOOF5_hb1PrxJLhhRxfCLkNSOh-61Mvh3DJKOcMnG2eOPsmH_4R_I-SPJB-Df0NTB70-vPiDRtKOS3qK-Duhc8mR9-jyoOvhKhyJH-8FE5eOHHoy3BpC5Tieo_kV9LiZ41McHCF9iJmDPFTQPeiYHD5J_Cfy7DBz_IdxrXBRMTyeP9CSLeJQ8glyC18S5imeSHkSPBeavwgfHrqSD7l09Fl2mGMDVzmekAzS_Gi3HPJbIr0VvD2eJD8u-eAPxytyMccTTQ8u5YmR63iG5jm6UG3wJcmFyzFuNEclvcETfcSb4T-aDz0RWoGs5MQlg9mUBXlyodYjbId_lHke4vPxCFuO5-iNJkw-5FseJM9RckFPHJ-kH3USNL_w4i7xpT5iHvlCVOIR5viFJyFK2Yd59DzqHe8wNUfJF1rwakJTZdB_TJkk5Ntx6YOb7MHj40SZh1ERZv3wD3yaohmzC-2DyM_xND_e48-CWx-6H5FC6ApxpUf-4jpyuEo64VLCZsrwHXcWlBcaDdeWI6Zz5D9qQ0wz4WNPPPCYWWgv6OT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csJjua69BsfFpKPDrCV4fPIFe-4IknofKNo9O0Q9L4oFauoBzaiD7eG018oZSj44nW4HlCNPFioa2CPMyFUzye5vjR7mgibTitiRh5Yj7aCQAIMEQoACCQQABhCBNGCMGUEcAYYg1AQCAhDDAAAAagAQAQAAh0BmBCiPAMEHOUAAogASCBBAAklFBEEWaEIkQAAAQjQAgAgHHCIASIA0gQQwQASBggBBFKUCMAIFQSBIQERAnCECRWEACEQJIipYABnIEhACECEUAIs8wg4QRCACBmBCAEKAEIAwYpABSACAAECASCCEKgE04oYBRQChgHhABkAUEAEAIwAwAgQFAgFGMUGcIoA0AIARgAyBhAFKIKCEOIAgQZIARARhgggBGUAYiRAUAIRYQEBABAkBAECOMMIgAIhIQBCiCFCHBMEASAAEoACogoCAFGgGUGWIUAMIgRBIAzhgAFFAJEAEIEgAwZoBgAmCFmhKEMGAAUAAYsQgABgChgNAUGAASIgEAYB4gRQABBBGMGCKEAAIwggShwCChkgGIEGQaocoQBoLRBSACOHALEMQAEAkwAYoAkTDkDICEKIUMQAEQEQRRAgBCJACJCIWSAAKwBQYQABEkCBRHAAEUAoAJIgYBQTAkDAAEIIGEEMIsQx4wAwhgiEQFCGAQQA0oY4gUhCgElgEHEOECEUAYhJAQwxBgJJANIUQKEIYIoARgDhhlAHFBIIAmQQRYhoAhhCBgnLCKEKCEQIQEIR4RTCgkkCAKGCmQQQQAQgAQFgBFBCCGSAwAEIcoIoJQEDCHhEDAKKmCREswQohAgiglkACACKgOhMUAhRgwCBAipEFGMAAGEUABYhAhSAiEFoFEQASGAIAAxJQiESDEHgCEISAEQEAAIJwhAShGoBAUAUCaIUAwIgQgzghgggECAKCIcMQoJxYgSwABlhACAMgMAEkwCpCBzhgADGDACWMIEA0YbIQBiQAAgGCFAKCCEJBAAAYwhAGmiCCOOAIEcMwAIggBzjBhHmHeMSCGIEggiAA0jTCHjCABCAAUQIUQJIowQggFkKBEAGCEBBMQgBIARBkGDCCFGCMMMIIAgQBgSSAI"; + + String response = client.lookup(duration, fingerprint); + AudioTrack info = client.parse(response); + + assertEquals("周杰倫", info.getArtist()); + assertEquals("聽媽媽的話", info.getTitle()); + } + + @BeforeClass + @AfterClass + public static void clearCache() { + CacheManager.getInstance().clearAll(); + } + +} diff --git a/test/net/filebot/web/WebTestSuite.java b/test/net/filebot/web/WebTestSuite.java index ebba27f3..c58ce262 100644 --- a/test/net/filebot/web/WebTestSuite.java +++ b/test/net/filebot/web/WebTestSuite.java @@ -5,7 +5,7 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, TMDbClientTest.class, IMDbClientTest.class, OpenSubtitlesXmlRpcTest.class }) +@SuiteClasses({ AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, TMDbClientTest.class, IMDbClientTest.class, OpenSubtitlesXmlRpcTest.class, AcoustIDClientTest.class }) public class WebTestSuite { }