forked from j62/ctbrec
Remove handling for online states private and group
They don't seem to affect the recording of the stream
This commit is contained in:
parent
39c1fd94ba
commit
9cd9bdf973
|
@ -4,6 +4,8 @@ import static ctbrec.Model.State.*;
|
|||
import static ctbrec.io.HttpConstants.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -32,6 +34,8 @@ public class Showup extends AbstractSite {
|
|||
public static final String BASE_URL = "https://showup.tv";
|
||||
|
||||
private ShowupHttpClient httpClient;
|
||||
private Instant lastModelListUpdate = Instant.EPOCH;
|
||||
private List<Model> models = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -63,44 +67,49 @@ public class Showup extends AbstractSite {
|
|||
}
|
||||
|
||||
public List<Model> getModelList() throws IOException {
|
||||
String url = getBaseUrl() + "/site/get_stream_list/big";
|
||||
Request req = new Request.Builder()
|
||||
.url(url)
|
||||
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
||||
.build();
|
||||
if(Duration.between(lastModelListUpdate, Instant.now()).getSeconds() > 10) {
|
||||
lastModelListUpdate = Instant.now();
|
||||
String url = getBaseUrl() + "/site/get_stream_list/big";
|
||||
Request req = new Request.Builder()
|
||||
.url(url)
|
||||
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
||||
.build();
|
||||
|
||||
try (Response response = getHttpClient().execute(req)) {
|
||||
if (response.isSuccessful()) {
|
||||
String body = response.body().string();
|
||||
LOG.trace(body);
|
||||
JSONObject json = new JSONObject(body);
|
||||
List<Model> models = new ArrayList<>();
|
||||
JSONArray list = json.getJSONArray("list");
|
||||
for (int i = 0; i < list.length(); i++) {
|
||||
JSONObject entry = list.getJSONObject(i);
|
||||
ShowupModel model = new ShowupModel();
|
||||
model.setUid(entry.getLong("uid"));
|
||||
model.setPreview(getBaseUrl() + "/files/" + entry.optString("big_img") + ".jpg");
|
||||
model.setDescription(entry.optString("description"));
|
||||
model.setName(entry.optString("username"));
|
||||
model.setUrl(getBaseUrl() + '/' + model.getName());
|
||||
if(entry.optInt("is_group") == 1) {
|
||||
model.setOnlineState(GROUP);
|
||||
} else if(entry.optInt("is_prv") == 1) {
|
||||
model.setOnlineState(PRIVATE);
|
||||
} else {
|
||||
try (Response response = getHttpClient().execute(req)) {
|
||||
if (response.isSuccessful()) {
|
||||
String body = response.body().string();
|
||||
LOG.trace(body);
|
||||
JSONObject json = new JSONObject(body);
|
||||
models = new ArrayList<>();
|
||||
JSONArray list = json.getJSONArray("list");
|
||||
for (int i = 0; i < list.length(); i++) {
|
||||
JSONObject entry = list.getJSONObject(i);
|
||||
ShowupModel model = new ShowupModel();
|
||||
model.setUid(entry.getLong("uid"));
|
||||
model.setPreview(getBaseUrl() + "/files/" + entry.optString("big_img") + ".jpg");
|
||||
model.setDescription(entry.optString("description"));
|
||||
model.setName(entry.optString("username"));
|
||||
model.setUrl(getBaseUrl() + '/' + model.getName());
|
||||
// TODO figure what these flags mean, because you can still stream the models, if is_prv or is_group is set ?!?
|
||||
// if(entry.optInt("is_group") == 1) {
|
||||
// model.setOnlineState(GROUP);
|
||||
// } else if(entry.optInt("is_prv") == 1) {
|
||||
// model.setOnlineState(PRIVATE);
|
||||
// } else {
|
||||
// model.setOnlineState(ONLINE);
|
||||
// }
|
||||
model.setOnlineState(ONLINE);
|
||||
model.setStreamId(entry.optString("stream_id"));
|
||||
model.setStreamTranscoderAddr(entry.optString("stream_transcoder_addr"));
|
||||
model.setSite(this);
|
||||
models.add(model);
|
||||
}
|
||||
model.setStreamId(entry.optString("stream_id"));
|
||||
model.setStreamTranscoderAddr(entry.optString("stream_transcoder_addr"));
|
||||
model.setSite(this);
|
||||
models.add(model);
|
||||
} else {
|
||||
throw new HttpException(response.code(), response.message());
|
||||
}
|
||||
return models;
|
||||
} else {
|
||||
throw new HttpException(response.code(), response.message());
|
||||
}
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ctbrec.sites.showup;
|
||||
|
||||
import static ctbrec.Model.State.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
|
@ -25,6 +27,7 @@ public class ShowupModel extends AbstractModel {
|
|||
private long uid;
|
||||
private String streamId;
|
||||
private String streamTranscoderAddr;
|
||||
private int[] resolution = new int[2];
|
||||
|
||||
@Override
|
||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||
|
@ -37,7 +40,8 @@ public class ShowupModel extends AbstractModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
return getOnlineState(false) == State.ONLINE;
|
||||
State state = getOnlineState(true);
|
||||
return state == ONLINE || state == GROUP || state == PRIVATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +78,7 @@ public class ShowupModel extends AbstractModel {
|
|||
|
||||
@Override
|
||||
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
||||
return new int[] { 480, 360 };
|
||||
return resolution;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue