mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Handle potential bad responses for RYD.
This commit is contained in:
parent
2050d367b1
commit
afd213b4c8
1 changed files with 10 additions and 4 deletions
|
@ -6,7 +6,7 @@ import me.kavin.piped.consts.Constants;
|
|||
import java.io.IOException;
|
||||
|
||||
import static me.kavin.piped.consts.Constants.mapper;
|
||||
import static me.kavin.piped.utils.RequestUtils.sendGet;
|
||||
import static me.kavin.piped.utils.RequestUtils.sendGetRaw;
|
||||
|
||||
public class RydHelper {
|
||||
public static double getDislikeRating(String videoId) throws IOException {
|
||||
|
@ -14,9 +14,15 @@ public class RydHelper {
|
|||
if (Constants.DISABLE_RYD)
|
||||
return -1;
|
||||
|
||||
var value = mapper.readTree(sendGet(Constants.RYD_PROXY_URL + "/votes/" + videoId))
|
||||
.get("rating");
|
||||
try (var resp = sendGetRaw(Constants.RYD_PROXY_URL + "/votes/" + videoId)) {
|
||||
|
||||
if (!resp.isSuccessful())
|
||||
return -1;
|
||||
|
||||
return mapper.readTree(resp.body().byteStream())
|
||||
.path("rating")
|
||||
.asDouble(-1);
|
||||
|
||||
return value == null ? -1 : value.asDouble(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue