Partially repaired LiveJasmin recordings

This commit is contained in:
0xb00bface 2023-06-04 15:22:51 +02:00
parent 2ab0c99c76
commit 7b7811dbfe
3 changed files with 35 additions and 16 deletions

View File

@ -42,8 +42,22 @@ public class LiveJasminModel extends AbstractModel {
} }
protected void loadModelInfo() throws IOException { 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(); 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, .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") "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, MIMETYPE_APPLICATION_JSON)
@ -55,6 +69,7 @@ public class LiveJasminModel extends AbstractModel {
if (response.isSuccessful()) { if (response.isSuccessful()) {
String body = response.body().string(); String body = response.body().string();
JSONObject json = new JSONObject(body); JSONObject json = new JSONObject(body);
//LOG.debug(json.toString(2));
if (json.optBoolean("success")) { if (json.optBoolean("success")) {
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
modelInfo = new LiveJasminModelInfo.LiveJasminModelInfoBuilder() modelInfo = new LiveJasminModelInfo.LiveJasminModelInfoBuilder()
@ -62,10 +77,13 @@ public class LiveJasminModel extends AbstractModel {
.sbHash(data.optString("sb_hash", null)) .sbHash(data.optString("sb_hash", null))
.sessionId("m12345678901234567890123456789012") .sessionId("m12345678901234567890123456789012")
.jsm2session(getSite().getHttpClient().getCookiesByName("session").get(0).value()) .jsm2session(getSite().getHttpClient().getCookiesByName("session").get(0).value())
.performerId(getName()) .performerId(data.optString("performer_id", getName()))
.clientInstanceId(randomClientInstanceId()) .clientInstanceId(randomClientInstanceId())
.status(data.optInt("status", -1)) .status(data.optInt("status", -1))
.build(); .build();
if (data.has("channelsiteurl")) {
setUrl(LiveJasmin.baseUrl + data.getString("channelsiteurl"));
}
onlineState = mapStatus(modelInfo.getStatus()); onlineState = mapStatus(modelInfo.getStatus());
online = onlineState == State.ONLINE online = onlineState == State.ONLINE
&& StringUtil.isNotBlank(modelInfo.getSbIp()) && StringUtil.isNotBlank(modelInfo.getSbIp())
@ -235,10 +253,5 @@ public class LiveJasminModel extends AbstractModel {
@Override @Override
public RecordingProcess createDownload() { public RecordingProcess createDownload() {
return new LiveJasminWebrtcDownload(getSite().getHttpClient()); return new LiveJasminWebrtcDownload(getSite().getHttpClient());
// if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
// return new LiveJasminHlsDownload(getSite().getHttpClient());
// } else {
// return new LiveJasminMergedHlsDownload(getSite().getHttpClient());
// }
} }
} }

View File

@ -85,15 +85,15 @@ public class LiveJasminStreamRegistration {
.put("peekPatternJsm2", true) .put("peekPatternJsm2", true)
.put("chatHistoryRequired", true) .put("chatHistoryRequired", true)
); );
log.trace("Stream registration\n{}", register.toString(2)); log.debug("Stream registration\n{}", register.toString(2));
webSocket.send(register.toString()); send(register.toString());
webSocket.send(new JSONObject().put(KEY_EVENT, "ping").toString()); send(new JSONObject().put(KEY_EVENT, "ping").toString());
webSocket.send(new JSONObject() send(new JSONObject()
.put(KEY_EVENT, "call") .put(KEY_EVENT, "call")
.put(KEY_FUNC_NAME, "makeActive") .put(KEY_FUNC_NAME, "makeActive")
.put("data", new JSONArray()) .put("data", new JSONArray())
.toString()); .toString());
webSocket.send(new JSONObject() send(new JSONObject()
.put(KEY_EVENT, "call") .put(KEY_EVENT, "call")
.put(KEY_FUNC_NAME, "setVideo") .put(KEY_FUNC_NAME, "setVideo")
.put("data", new JSONArray() .put("data", new JSONArray()
@ -103,7 +103,7 @@ public class LiveJasminStreamRegistration {
.put(modelInfo.getJsm2session()) .put(modelInfo.getJsm2session())
) )
.toString()); .toString());
webSocket.send(new JSONObject() send(new JSONObject()
.put(KEY_EVENT, "connectSharedObject") .put(KEY_EVENT, "connectSharedObject")
.put("name", "data/chat_so") .put("name", "data/chat_so")
.toString()); .toString());
@ -118,6 +118,7 @@ public class LiveJasminStreamRegistration {
@Override @Override
public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) { public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {
log.debug("< {}", text);
JSONObject message = new JSONObject(text); JSONObject message = new JSONObject(text);
if (message.opt(KEY_EVENT).equals("pong")) { if (message.opt(KEY_EVENT).equals("pong")) {
new Thread(() -> { new Thread(() -> {
@ -126,7 +127,7 @@ public class LiveJasminStreamRegistration {
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
webSocket.send(new JSONObject().put(KEY_EVENT, "ping").toString()); send(new JSONObject().put(KEY_EVENT, "ping").toString());
}).start(); }).start();
} else if (message.optString(KEY_EVENT).equals("updateSharedObject") && message.optString("name").equals("data/chat_so")) { } else if (message.optString(KEY_EVENT).equals("updateSharedObject") && message.optString("name").equals("data/chat_so")) {
log.trace(message.toString(2)); log.trace(message.toString(2));
@ -158,7 +159,7 @@ public class LiveJasminStreamRegistration {
) )
); );
streamCount++; streamCount++;
webSocket.send(getVideoData.toString()); send(getVideoData.toString());
} }
} }
} }
@ -192,6 +193,11 @@ public class LiveJasminStreamRegistration {
log.trace("onClosing {} {}", code, reason); log.trace("onClosing {} {}", code, reason);
awaitBarrier(); awaitBarrier();
} }
private void send(String msg) {
log.debug(" > {}", msg);
webSocket.send(msg);
}
}); });
log.debug("Waiting for websocket to return"); log.debug("Waiting for websocket to return");

View File

@ -231,7 +231,7 @@ public class LiveJasminWebrtcDownload extends AbstractDownload {
long secondsToWait = 30; long secondsToWait = 30;
for (int i = 0; i < secondsToWait; i++) { for (int i = 0; i < secondsToWait; i++) {
if (ws == null) { if (ws == null) {
break; return;
} else { } else {
try { try {
Thread.sleep(1000); Thread.sleep(1000);