forked from j62/ctbrec
1
0
Fork 0

Use liveState to determine, if a model is online

This commit is contained in:
0xboobface 2019-09-21 12:50:05 +02:00
parent 7319b6251a
commit 84a02d7432
1 changed files with 14 additions and 1 deletions

View File

@ -76,7 +76,7 @@ public class StreamateFollowedService extends PaginatedScheduledService {
StreamateModel model = (StreamateModel) streamate.createModel(nickname);
model.setId(p.getLong("id"));
model.setPreview(p.getString("thumbnail"));
boolean online = p.optBoolean("online");
boolean online = p.optBoolean("online") && notPrivateEtc(p);
model.setOnline(online);
if (online == showOnline) {
models.add(model);
@ -91,6 +91,19 @@ public class StreamateFollowedService extends PaginatedScheduledService {
}
}
}
private boolean notPrivateEtc(JSONObject p) {
if (p.has("liveState")) {
JSONObject liveState = p.getJSONObject("liveState");
boolean offline = liveState.optBoolean("onBreak")
|| liveState.optBoolean("privateChat")
|| liveState.optBoolean("exclusiveShow")
|| liveState.optBoolean("specialShow")
|| liveState.optBoolean("goldShow");
return !offline;
}
return false;
}
};
}