mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-01 00:02:55 +01:00
fix RYD voting
This commit is contained in:
parent
48c268b0bc
commit
6bac0407bb
@ -21,20 +21,26 @@ public class Requester {
|
||||
}
|
||||
|
||||
public static String parseJson(HttpURLConnection connection) throws IOException {
|
||||
return parseJson(connection.getInputStream());
|
||||
return parseJson(connection.getInputStream(), false);
|
||||
}
|
||||
|
||||
public static String parseJson(InputStream inputStream) throws IOException {
|
||||
public static String parseJson(InputStream inputStream, boolean isError) throws IOException {
|
||||
StringBuilder jsonBuilder = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
jsonBuilder.append(line).append("\n");
|
||||
jsonBuilder.append(line);
|
||||
if (isError)
|
||||
jsonBuilder.append("\n");
|
||||
}
|
||||
inputStream.close();
|
||||
return jsonBuilder.toString();
|
||||
}
|
||||
|
||||
public static String parseErrorJson(HttpURLConnection connection) throws IOException {
|
||||
return parseJson(connection.getErrorStream(), true);
|
||||
}
|
||||
|
||||
public static JSONObject getJSONObject(HttpURLConnection connection) throws Exception {
|
||||
return new JSONObject(parseJsonAndDisconnect(connection));
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class SBRequester {
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_duplicate");
|
||||
break;
|
||||
case 403:
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_forbidden", Requester.parseJson(connection.getErrorStream()));
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_forbidden", Requester.parseErrorJson(connection));
|
||||
break;
|
||||
case 429:
|
||||
SponsorBlockUtils.messageToToast = str("submit_failed_rate_limit");
|
||||
@ -137,7 +137,7 @@ public class SBRequester {
|
||||
SponsorBlockUtils.messageToToast = str("vote_succeeded");
|
||||
break;
|
||||
case 403:
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_forbidden", Requester.parseJson(connection.getErrorStream()));
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_forbidden", Requester.parseErrorJson(connection));
|
||||
break;
|
||||
default:
|
||||
SponsorBlockUtils.messageToToast = str("vote_failed_unknown_error", responseCode, connection.getResponseMessage());
|
||||
|
Loading…
Reference in New Issue
Block a user