From 341846e94eb6b4b317f4200780da8acaf09019b0 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Mon, 24 May 2021 20:34:25 +0200 Subject: [PATCH] Improve behaviour of getOnlineState for XloveCam --- .../ctbrec/sites/xlovecam/XloveCamModel.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/ctbrec/sites/xlovecam/XloveCamModel.java b/common/src/main/java/ctbrec/sites/xlovecam/XloveCamModel.java index d53c14c1..4d631e28 100644 --- a/common/src/main/java/ctbrec/sites/xlovecam/XloveCamModel.java +++ b/common/src/main/java/ctbrec/sites/xlovecam/XloveCamModel.java @@ -45,7 +45,7 @@ public class XloveCamModel extends AbstractModel { @Override public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException { - if (ignoreCache || onlineState == UNKNOWN) { + if (ignoreCache) { String body = getModelPage(); Matcher m = HLS_PLAYLIST_PATTERN.matcher(body); online = m.find(); @@ -54,6 +54,23 @@ public class XloveCamModel extends AbstractModel { return online; } + @Override + public State getOnlineState(boolean failFast) throws IOException, ExecutionException { + if (failFast && onlineState != UNKNOWN) { + return onlineState; + } else { + try { + onlineState = isOnline(true) ? ONLINE : OFFLINE; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + onlineState = OFFLINE; + } catch (IOException | ExecutionException e) { + onlineState = OFFLINE; + } + return onlineState; + } + } + @Override public List getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException, JAXBException { MasterPlaylist masterPlaylist = getMasterPlaylist();