From 7f249abbaa6b4a06ed04f3d4a86840b697194002 Mon Sep 17 00:00:00 2001
From: Katsute <58778985+Katsute@users.noreply.github.com>
Date: Mon, 5 Dec 2022 09:55:00 -0500
Subject: [PATCH] fix 429, fix translate &
---
pom.xml | 2 +-
src/main/java/dev/katsute/mis/RequestHandler.java | 11 +++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index f237d2a..983a217 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
dev.katsute
mta-information-site
- 3.37.0
+ 3.37.1
UTF-8
diff --git a/src/main/java/dev/katsute/mis/RequestHandler.java b/src/main/java/dev/katsute/mis/RequestHandler.java
index 3f50cfe..4970cc6 100644
--- a/src/main/java/dev/katsute/mis/RequestHandler.java
+++ b/src/main/java/dev/katsute/mis/RequestHandler.java
@@ -431,7 +431,7 @@ static String translate(final String q, final String from, final String to){
put("dj", "1"); // as json
put("sl", from); // source
put("tl", to); // target
- put("q", q.replace("@", "at")); // query
+ put("q", q.replace("@", "at").replace("&", "and")); // query
}};
HttpURLConnection conn = null;
@@ -471,7 +471,14 @@ static String translate(final String q, final String from, final String to){
return str.trim();
}
}catch(final IOException e){
- e.printStackTrace();
+ try{
+ if(conn.getResponseCode() == 429)
+ System.out.println("Translate API is rate limited");
+ else
+ e.printStackTrace();
+ }catch (final IOException e1) {
+ e1.printStackTrace();
+ }
}finally{
if(conn != null)
conn.disconnect();