Extract unchecked model state from unknown

Allows to know if online check was run or not
This commit is contained in:
reusedname 2025-02-24 22:32:13 +05:00
parent 4419a8d723
commit c6389b9481
15 changed files with 19 additions and 17 deletions

View File

@ -22,7 +22,7 @@ public class ShowNotification extends Action {
switch(evt.getType()) {
case MODEL_STATUS_CHANGED:
ModelStateChangedEvent modelEvent = (ModelStateChangedEvent) evt;
if (modelEvent.getOldState() == Model.State.UNKNOWN) {
if (modelEvent.getOldState() == Model.State.UNCHECKED) {
return;
}
var m = modelEvent.getModel();

View File

@ -33,7 +33,7 @@ public abstract class AbstractModel implements Model {
private boolean forcePriority = false;
private boolean markedForLaterRecording = false;
protected transient Site site;
protected State onlineState = State.UNKNOWN;
protected State onlineState = State.UNCHECKED;
private Instant lastSeen;
private Instant lastRecorded;
private Instant recordUntil;

View File

@ -26,7 +26,8 @@ public interface Model extends Comparable<Model>, Serializable {
AWAY("away"),
PRIVATE("private"),
GROUP("group"),
UNKNOWN("unknown");
UNKNOWN("unknown"),
UNCHECKED("unchecked");
final String display;

View File

@ -21,7 +21,7 @@ import java.util.Map;
import java.util.concurrent.*;
import static ctbrec.Model.State.OFFLINE;
import static ctbrec.Model.State.UNKNOWN;
import static ctbrec.Model.State.UNCHECKED;
public class OnlineMonitor extends Thread {
private static final Logger LOG = LoggerFactory.getLogger(OnlineMonitor.class);
@ -101,7 +101,7 @@ public class OnlineMonitor extends Thread {
}
private void setModelStateNotified(Model model, Model.State state) {
Model.State oldState = states.getOrDefault(model, UNKNOWN);
Model.State oldState = states.getOrDefault(model, UNCHECKED);
states.put(model, state);
if (state != oldState) {
EventBusHolder.BUS.post(new ModelStateChangedEvent(model, oldState, state));

View File

@ -55,7 +55,7 @@ public class AmateurTvModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast || onlineState == UNKNOWN) {
if (!failFast || onlineState == UNKNOWN || onlineState == UNCHECKED) {
try {
onlineState = isOnline(true) ? ONLINE : OFFLINE;
} catch (InterruptedException e) {

View File

@ -86,7 +86,8 @@ public class Cam4Model extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast && onlineState == UNKNOWN) {
// TODO: should it be !failFast || onlineState ? as in AbstractHlsModel
if (!failFast && (onlineState == UNKNOWN || onlineState == UNCHECKED)) {
try {
modelInfo = loadModelInfo();
} catch (Exception e) {

View File

@ -205,7 +205,7 @@ public class CamsodaModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast && onlineState == UNKNOWN) {
if (!failFast && (onlineState == UNKNOWN || onlineState == UNCHECKED)) {
loadModel();
}
return onlineState;

View File

@ -145,10 +145,10 @@ public class ChaturbateModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (failFast) {
if (onlineState != UNKNOWN) {
if (onlineState != UNCHECKED) {
return onlineState;
} else {
setOnlineStateByRoomStatus(Optional.ofNullable(streamInfo).map(si -> si.room_status).orElse("unknown"));
setOnlineStateByRoomStatus(Optional.ofNullable(streamInfo).map(si -> si.room_status).orElse(null));
}
} else {
if (isOffline()) {

View File

@ -62,7 +62,7 @@ public class DreamcamModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (failFast && onlineState != UNKNOWN) {
if (failFast && onlineState != UNKNOWN && onlineState != UNCHECKED) {
return onlineState;
} else {
try {

View File

@ -96,7 +96,7 @@ public class Fc2Model extends AbstractModel {
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (failFast) {
return onlineState;
} else if (Objects.equals(onlineState, State.UNKNOWN)) {
} else if (onlineState == State.UNKNOWN || onlineState == State.UNCHECKED) {
loadModelInfo();
}
return onlineState;

View File

@ -82,7 +82,7 @@ public class MyFreeCamsModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (state == null) {
return State.UNKNOWN;
return State.UNCHECKED;
}
if (!failFast) {

View File

@ -61,7 +61,7 @@ public class StreamateModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast && onlineState == UNKNOWN) {
if (!failFast && (onlineState == UNKNOWN || onlineState == UNCHECKED)) {
return online ? ONLINE : OFFLINE;
}
return onlineState;

View File

@ -70,7 +70,7 @@ public class StreamrayModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast || onlineState == UNKNOWN) {
if (!failFast || onlineState == UNKNOWN || onlineState == UNCHECKED) {
try {
onlineState = isOnline(true) ? ONLINE : OFFLINE;
} catch (InterruptedException e) {

View File

@ -71,7 +71,7 @@ public class WinkTvModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast || onlineState == UNKNOWN) {
if (!failFast || onlineState == UNKNOWN || onlineState == UNCHECKED) {
try {
onlineState = isOnline(true) ? ONLINE : OFFLINE;
} catch (InterruptedException e) {

View File

@ -47,7 +47,7 @@ public class XloveCamModel extends AbstractModel {
@Override
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
if (!failFast || onlineState == UNKNOWN) {
if (!failFast || onlineState == UNKNOWN || onlineState == UNCHECKED) {
try {
onlineState = isOnline(true) ? ONLINE : OFFLINE;
} catch (InterruptedException e) {