mirror of
https://github.com/TeamPiped/Piped-Backend
synced 2025-09-06 13:31:17 +02:00
Handle potential bad responses for RYD.
This commit is contained in:
parent
2050d367b1
commit
afd213b4c8
@ -6,7 +6,7 @@ import me.kavin.piped.consts.Constants;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static me.kavin.piped.consts.Constants.mapper;
|
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 class RydHelper {
|
||||||
public static double getDislikeRating(String videoId) throws IOException {
|
public static double getDislikeRating(String videoId) throws IOException {
|
||||||
@ -14,9 +14,15 @@ public class RydHelper {
|
|||||||
if (Constants.DISABLE_RYD)
|
if (Constants.DISABLE_RYD)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
var value = mapper.readTree(sendGet(Constants.RYD_PROXY_URL + "/votes/" + videoId))
|
try (var resp = sendGetRaw(Constants.RYD_PROXY_URL + "/votes/" + videoId)) {
|
||||||
.get("rating");
|
|
||||||
|
|
||||||
return value == null ? -1 : value.asDouble(-1);
|
if (!resp.isSuccessful())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return mapper.readTree(resp.body().byteStream())
|
||||||
|
.path("rating")
|
||||||
|
.asDouble(-1);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user