Don't fail hard when LBRY throws errors.

This commit is contained in:
FireMaskterK 2021-10-06 16:37:30 +01:00
parent cad4e2cc33
commit 2c7baa0710
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -121,7 +121,7 @@ public class ResponseHelper {
try { try {
return getLBRYId(videoId); return getLBRYId(videoId);
} catch (Exception e) { } catch (Exception e) {
ExceptionUtils.rethrow(e); ExceptionHandler.handle(e);
} }
return null; return null;
}); });
@ -130,7 +130,7 @@ public class ResponseHelper {
try { try {
return getLBRYStreamURL(futureLbryId); return getLBRYStreamURL(futureLbryId);
} catch (Exception e) { } catch (Exception e) {
ExceptionUtils.rethrow(e); ExceptionHandler.handle(e);
} }
return null; return null;
}); });
@ -945,12 +945,16 @@ public class ResponseHelper {
String lbryId = futureLbryId.get(); String lbryId = futureLbryId.get();
if (!lbryId.isEmpty()) if (!lbryId.isEmpty())
return new JSONObject(Constants.h2client.send(HttpRequest return new JSONObject(
.newBuilder(URI.create("https://api.lbry.tv/api/v1/proxy?m=get")) Constants.h2client.send(
.POST(BodyPublishers.ofString( HttpRequest.newBuilder(URI.create("https://api.lbry.tv/api/v1/proxy?m=get"))
String.valueOf(new JSONObject().put("jsonrpc", "2.0").put("method", "get").put("params", .POST(BodyPublishers.ofString(
new JSONObject().put("uri", "lbry://" + lbryId).put("save_file", true))))) String.valueOf(new JSONObject().put("id", System.currentTimeMillis())
.build(), BodyHandlers.ofString()).body()).getJSONObject("result").getString("streaming_url"); .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; return null;