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