mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-21 01:07:32 +01:00
fix(YouTube - Return YouTube Dislike): Do not show error toast if API success response contains new lines (#612)
This commit is contained in:
parent
e9cd898651
commit
9108205445
@ -279,7 +279,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
// do not disconnect, the same server connection will likely be used again soon
|
// Do not disconnect, the same server connection will likely be used again soon.
|
||||||
JSONObject json = Requester.parseJSONObject(connection);
|
JSONObject json = Requester.parseJSONObject(connection);
|
||||||
try {
|
try {
|
||||||
RYDVoteData votingData = new RYDVoteData(json);
|
RYDVoteData votingData = new RYDVoteData(json);
|
||||||
@ -377,20 +377,17 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String result = null;
|
|
||||||
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
result = Requester.parseJson(connection);
|
Logger.printDebug(() -> "Registration confirmation successful");
|
||||||
if (result.equalsIgnoreCase("true")) {
|
return userId;
|
||||||
Logger.printDebug(() -> "Registration confirmation successful");
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final String resultLog = result == null ? "(no response)" : result;
|
|
||||||
|
// Something went wrong, might as well disconnect.
|
||||||
|
String response = Requester.parseJsonAndDisconnect(connection);
|
||||||
Logger.printInfo(() -> "Failed to confirm registration for user: " + userId
|
Logger.printInfo(() -> "Failed to confirm registration for user: " + userId
|
||||||
+ " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog);
|
+ " solution: " + solution + " responseCode: " + responseCode + " response: '" + response + "''");
|
||||||
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
||||||
null, true);
|
null, true);
|
||||||
connection.disconnect(); // something went wrong, might as well disconnect
|
|
||||||
} catch (SocketTimeoutException ex) {
|
} catch (SocketTimeoutException ex) {
|
||||||
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
|
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -461,6 +458,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
String solution = solvePuzzle(challenge, difficulty);
|
String solution = solvePuzzle(challenge, difficulty);
|
||||||
return confirmVote(videoId, userId, solution);
|
return confirmVote(videoId, userId, solution);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote
|
Logger.printInfo(() -> "Failed to send vote for video: " + videoId + " vote: " + vote
|
||||||
+ " response code was: " + responseCode);
|
+ " response code was: " + responseCode);
|
||||||
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
||||||
@ -501,20 +499,17 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String result = null;
|
|
||||||
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
result = Requester.parseJson(connection);
|
Logger.printDebug(() -> "Vote confirm successful for video: " + videoId);
|
||||||
if (result.equalsIgnoreCase("true")) {
|
return true;
|
||||||
Logger.printDebug(() -> "Vote confirm successful for video: " + videoId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final String resultLog = result == null ? "(no response)" : result;
|
|
||||||
|
// Something went wrong, might as well disconnect.
|
||||||
|
String response = Requester.parseJsonAndDisconnect(connection);
|
||||||
Logger.printInfo(() -> "Failed to confirm vote for video: " + videoId
|
Logger.printInfo(() -> "Failed to confirm vote for video: " + videoId
|
||||||
+ " solution: " + solution + " responseCode: " + responseCode + " responseString: " + resultLog);
|
+ " solution: " + solution + " responseCode: " + responseCode + " response: '" + response + "'");
|
||||||
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
handleConnectionError(str("revanced_ryd_failure_connection_status_code", responseCode),
|
||||||
null, true);
|
null, true);
|
||||||
connection.disconnect(); // something went wrong, might as well disconnect
|
|
||||||
} catch (SocketTimeoutException ex) {
|
} catch (SocketTimeoutException ex) {
|
||||||
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
|
handleConnectionError(str("revanced_ryd_failure_connection_timeout"), ex, false);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user