Partially repaired LiveJasmin recordings
This commit is contained in:
parent
2ab0c99c76
commit
7b7811dbfe
|
@ -42,8 +42,22 @@ public class LiveJasminModel extends AbstractModel {
|
|||
}
|
||||
|
||||
protected void loadModelInfo() throws IOException {
|
||||
Request req = new Request.Builder().url(LiveJasmin.baseUrl)
|
||||
//.header(USER_AGENT,
|
||||
// "Mozilla/5.0 (iPhone; CPU OS 10_14 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Mobile/14E304 Safari/605.1.15")
|
||||
//.header(ACCEPT, MIMETYPE_APPLICATION_JSON)
|
||||
.header(ACCEPT_LANGUAGE, Locale.ENGLISH.getLanguage())
|
||||
//.header(REFERER, getSite().getBaseUrl())
|
||||
//.header(X_REQUESTED_WITH, XML_HTTP_REQUEST)
|
||||
.build();
|
||||
try (Response response = getSite().getHttpClient().execute(req)) {
|
||||
// do nothing we just want the cookies
|
||||
LOG.debug("Initial request succeeded: {} - {}", response.isSuccessful(), response.code());
|
||||
|
||||
}
|
||||
|
||||
String url = LiveJasmin.baseUrl + "/en/flash/get-performer-details/" + getName();
|
||||
Request req = new Request.Builder().url(url)
|
||||
req = new Request.Builder().url(url)
|
||||
.header(USER_AGENT,
|
||||
"Mozilla/5.0 (iPhone; CPU OS 10_14 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Mobile/14E304 Safari/605.1.15")
|
||||
.header(ACCEPT, MIMETYPE_APPLICATION_JSON)
|
||||
|
@ -55,6 +69,7 @@ public class LiveJasminModel extends AbstractModel {
|
|||
if (response.isSuccessful()) {
|
||||
String body = response.body().string();
|
||||
JSONObject json = new JSONObject(body);
|
||||
//LOG.debug(json.toString(2));
|
||||
if (json.optBoolean("success")) {
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
modelInfo = new LiveJasminModelInfo.LiveJasminModelInfoBuilder()
|
||||
|
@ -62,10 +77,13 @@ public class LiveJasminModel extends AbstractModel {
|
|||
.sbHash(data.optString("sb_hash", null))
|
||||
.sessionId("m12345678901234567890123456789012")
|
||||
.jsm2session(getSite().getHttpClient().getCookiesByName("session").get(0).value())
|
||||
.performerId(getName())
|
||||
.performerId(data.optString("performer_id", getName()))
|
||||
.clientInstanceId(randomClientInstanceId())
|
||||
.status(data.optInt("status", -1))
|
||||
.build();
|
||||
if (data.has("channelsiteurl")) {
|
||||
setUrl(LiveJasmin.baseUrl + data.getString("channelsiteurl"));
|
||||
}
|
||||
onlineState = mapStatus(modelInfo.getStatus());
|
||||
online = onlineState == State.ONLINE
|
||||
&& StringUtil.isNotBlank(modelInfo.getSbIp())
|
||||
|
@ -235,10 +253,5 @@ public class LiveJasminModel extends AbstractModel {
|
|||
@Override
|
||||
public RecordingProcess createDownload() {
|
||||
return new LiveJasminWebrtcDownload(getSite().getHttpClient());
|
||||
// if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
|
||||
// return new LiveJasminHlsDownload(getSite().getHttpClient());
|
||||
// } else {
|
||||
// return new LiveJasminMergedHlsDownload(getSite().getHttpClient());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,15 +85,15 @@ public class LiveJasminStreamRegistration {
|
|||
.put("peekPatternJsm2", true)
|
||||
.put("chatHistoryRequired", true)
|
||||
);
|
||||
log.trace("Stream registration\n{}", register.toString(2));
|
||||
webSocket.send(register.toString());
|
||||
webSocket.send(new JSONObject().put(KEY_EVENT, "ping").toString());
|
||||
webSocket.send(new JSONObject()
|
||||
log.debug("Stream registration\n{}", register.toString(2));
|
||||
send(register.toString());
|
||||
send(new JSONObject().put(KEY_EVENT, "ping").toString());
|
||||
send(new JSONObject()
|
||||
.put(KEY_EVENT, "call")
|
||||
.put(KEY_FUNC_NAME, "makeActive")
|
||||
.put("data", new JSONArray())
|
||||
.toString());
|
||||
webSocket.send(new JSONObject()
|
||||
send(new JSONObject()
|
||||
.put(KEY_EVENT, "call")
|
||||
.put(KEY_FUNC_NAME, "setVideo")
|
||||
.put("data", new JSONArray()
|
||||
|
@ -103,7 +103,7 @@ public class LiveJasminStreamRegistration {
|
|||
.put(modelInfo.getJsm2session())
|
||||
)
|
||||
.toString());
|
||||
webSocket.send(new JSONObject()
|
||||
send(new JSONObject()
|
||||
.put(KEY_EVENT, "connectSharedObject")
|
||||
.put("name", "data/chat_so")
|
||||
.toString());
|
||||
|
@ -118,6 +118,7 @@ public class LiveJasminStreamRegistration {
|
|||
|
||||
@Override
|
||||
public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {
|
||||
log.debug("< {}", text);
|
||||
JSONObject message = new JSONObject(text);
|
||||
if (message.opt(KEY_EVENT).equals("pong")) {
|
||||
new Thread(() -> {
|
||||
|
@ -126,7 +127,7 @@ public class LiveJasminStreamRegistration {
|
|||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
webSocket.send(new JSONObject().put(KEY_EVENT, "ping").toString());
|
||||
send(new JSONObject().put(KEY_EVENT, "ping").toString());
|
||||
}).start();
|
||||
} else if (message.optString(KEY_EVENT).equals("updateSharedObject") && message.optString("name").equals("data/chat_so")) {
|
||||
log.trace(message.toString(2));
|
||||
|
@ -158,7 +159,7 @@ public class LiveJasminStreamRegistration {
|
|||
)
|
||||
);
|
||||
streamCount++;
|
||||
webSocket.send(getVideoData.toString());
|
||||
send(getVideoData.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,6 +193,11 @@ public class LiveJasminStreamRegistration {
|
|||
log.trace("onClosing {} {}", code, reason);
|
||||
awaitBarrier();
|
||||
}
|
||||
|
||||
private void send(String msg) {
|
||||
log.debug(" > {}", msg);
|
||||
webSocket.send(msg);
|
||||
}
|
||||
});
|
||||
|
||||
log.debug("Waiting for websocket to return");
|
||||
|
|
|
@ -231,7 +231,7 @@ public class LiveJasminWebrtcDownload extends AbstractDownload {
|
|||
long secondsToWait = 30;
|
||||
for (int i = 0; i < secondsToWait; i++) {
|
||||
if (ws == null) {
|
||||
break;
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
|
|
Loading…
Reference in New Issue