From 1c1dd0545553232002c6920a4a679c4cfc836d25 Mon Sep 17 00:00:00 2001 From: FireMaskterK <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 12 Oct 2021 11:44:21 +0100 Subject: [PATCH] Add timeout for LBRY calls. --- .../java/me/kavin/piped/utils/ResponseHelper.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 833b99f..bc3ab4e 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -148,7 +148,13 @@ public class ResponseHelper { final List videoStreams = new ObjectArrayList<>(); final List audioStreams = new ObjectArrayList<>(); - final String lbryURL = futureLBRY.get(); + String lbryURL = null; + + try { + lbryURL = futureLBRY.get(3, TimeUnit.SECONDS); + } catch (Exception e) { + // ignored + } if (lbryURL != null) videoStreams.add(new PipedStream(lbryURL, "MP4", "LBRY", "video/mp4", false)); @@ -942,7 +948,12 @@ public class ResponseHelper { private static final String getLBRYStreamURL(CompletableFuture futureLbryId) throws IOException, InterruptedException, ExecutionException { - String lbryId = futureLbryId.get(); + String lbryId = ""; + try { + lbryId = futureLbryId.get(2, TimeUnit.SECONDS); + } catch (Exception e) { + // ignored + } if (!lbryId.isEmpty()) return new JSONObject(