forked from j62/ctbrec
1
0
Fork 0

Take boolean privateRoom into account for online state

This commit is contained in:
0xboobface 2018-11-28 11:47:40 +01:00
parent 33642705a0
commit 7edc79b0e3
1 changed files with 7 additions and 2 deletions

View File

@ -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();