From 2c7baa0710eade7a742096f41cae7d55ede9972e Mon Sep 17 00:00:00 2001 From: FireMaskterK <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:37:30 +0100 Subject: [PATCH] Don't fail hard when LBRY throws errors. --- .../me/kavin/piped/utils/ResponseHelper.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index c4a45fb..06b38fe 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -121,7 +121,7 @@ public class ResponseHelper { try { return getLBRYId(videoId); } catch (Exception e) { - ExceptionUtils.rethrow(e); + ExceptionHandler.handle(e); } return null; }); @@ -130,7 +130,7 @@ public class ResponseHelper { try { return getLBRYStreamURL(futureLbryId); } catch (Exception e) { - ExceptionUtils.rethrow(e); + ExceptionHandler.handle(e); } return null; }); @@ -945,12 +945,16 @@ public class ResponseHelper { String lbryId = futureLbryId.get(); if (!lbryId.isEmpty()) - return new JSONObject(Constants.h2client.send(HttpRequest - .newBuilder(URI.create("https://api.lbry.tv/api/v1/proxy?m=get")) - .POST(BodyPublishers.ofString( - String.valueOf(new JSONObject().put("jsonrpc", "2.0").put("method", "get").put("params", - new JSONObject().put("uri", "lbry://" + lbryId).put("save_file", true))))) - .build(), BodyHandlers.ofString()).body()).getJSONObject("result").getString("streaming_url"); + return new JSONObject( + Constants.h2client.send( + HttpRequest.newBuilder(URI.create("https://api.lbry.tv/api/v1/proxy?m=get")) + .POST(BodyPublishers.ofString( + String.valueOf(new JSONObject().put("id", System.currentTimeMillis()) + .put("jsonrpc", "2.0").put("method", "get").put("params", + new JSONObject().put("uri", "lbry://" + lbryId) + .put("save_file", true))))) + .build(), + BodyHandlers.ofString()).body()).getJSONObject("result").getString("streaming_url"); return null;