mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Fix LBRY timeouts.
This commit is contained in:
parent
3de3b55d3c
commit
1c8e8b190e
1 changed files with 11 additions and 14 deletions
|
@ -116,7 +116,7 @@ public class ResponseHelper {
|
|||
ExceptionUtils.rethrow(e);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}, Multithreading.getCachedExecutor());
|
||||
|
||||
CompletableFuture<String> futureLbryId = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
|
@ -125,16 +125,20 @@ public class ResponseHelper {
|
|||
ExceptionHandler.handle(e);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}, Multithreading.getCachedExecutor());
|
||||
|
||||
CompletableFuture<String> futureLBRY = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return getLBRYStreamURL(futureLbryId);
|
||||
String lbryId = null;
|
||||
|
||||
lbryId = futureLbryId.completeOnTimeout(null, 2, TimeUnit.SECONDS).get();
|
||||
|
||||
return getLBRYStreamURL(lbryId);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.handle(e);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}, Multithreading.getCachedExecutor());
|
||||
|
||||
final List<Subtitle> subtitles = new ObjectArrayList<>();
|
||||
final List<ChapterSegment> chapters = new ObjectArrayList<>();
|
||||
|
@ -157,7 +161,7 @@ public class ResponseHelper {
|
|||
String lbryURL = null;
|
||||
|
||||
try {
|
||||
lbryURL = futureLBRY.get(3, TimeUnit.SECONDS);
|
||||
lbryURL = futureLBRY.completeOnTimeout(null, 3, TimeUnit.SECONDS).get();
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
|
@ -970,17 +974,10 @@ public class ResponseHelper {
|
|||
.getJSONObject("data").getJSONObject("videos").optString(videoId);
|
||||
}
|
||||
|
||||
private static final String getLBRYStreamURL(CompletableFuture<String> futureLbryId)
|
||||
private static final String getLBRYStreamURL(String lbryId)
|
||||
throws IOException, InterruptedException, ExecutionException {
|
||||
|
||||
String lbryId = "";
|
||||
try {
|
||||
lbryId = futureLbryId.get(2, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (!lbryId.isEmpty())
|
||||
if (lbryId != null && !lbryId.isEmpty())
|
||||
return new JSONObject(
|
||||
Constants.h2client.send(
|
||||
HttpRequest.newBuilder(URI.create("https://api.lbry.tv/api/v1/proxy?m=get"))
|
||||
|
|
Loading…
Reference in a new issue