forked from j62/ctbrec
Take boolean privateRoom into account for online state
This commit is contained in:
parent
33642705a0
commit
7edc79b0e3
|
@ -5,6 +5,7 @@ import java.io.InputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
@ -39,6 +40,7 @@ public class Cam4Model extends AbstractModel {
|
|||
private String playlistUrl;
|
||||
private String onlineState = "offline";
|
||||
private int[] resolution = null;
|
||||
private boolean privateRoom = false;
|
||||
|
||||
@Override
|
||||
public boolean isOnline() throws IOException, ExecutionException, InterruptedException {
|
||||
|
@ -54,7 +56,9 @@ public class Cam4Model extends AbstractModel {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return Objects.equals("NORMAL", onlineState) && StringUtil.isNotBlank(playlistUrl);
|
||||
return (Objects.equals("NORMAL", onlineState) || Objects.equals("GROUP_SHOW_SELLING_TICKETS", onlineState))
|
||||
&& StringUtil.isNotBlank(playlistUrl)
|
||||
&& !privateRoom;
|
||||
}
|
||||
|
||||
private void loadModelDetails() throws IOException, ModelDetailsEmptyException {
|
||||
|
@ -71,6 +75,7 @@ public class Cam4Model extends AbstractModel {
|
|||
JSONObject details = json.getJSONObject(0);
|
||||
onlineState = details.getString("showType");
|
||||
playlistUrl = details.getString("hlsPreviewUrl");
|
||||
privateRoom = details.getBoolean("privateRoom");
|
||||
if(details.has("resolution")) {
|
||||
String res = details.getString("resolution");
|
||||
String[] tokens = res.split(":");
|
||||
|
@ -106,7 +111,7 @@ public class Cam4Model extends AbstractModel {
|
|||
if (playlist.hasStreamInfo()) {
|
||||
StreamSource src = new StreamSource();
|
||||
src.bandwidth = playlist.getStreamInfo().getBandwidth();
|
||||
src.height = playlist.getStreamInfo().getResolution().height;
|
||||
src.height = Optional.ofNullable(playlist.getStreamInfo()).map(si -> si.getResolution()).map(res -> res.height).orElse(0);
|
||||
String masterUrl = getPlaylistUrl();
|
||||
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);
|
||||
String segmentUri = baseUrl + playlist.getUri();
|
||||
|
|
Loading…
Reference in New Issue