From 7a0dc3a371e3e234fa0ab84c6d421a329c61b5de Mon Sep 17 00:00:00 2001 From: reusedname <155286845+reusedname@users.noreply.github.com> Date: Sun, 6 Apr 2025 16:51:56 +0500 Subject: [PATCH] new CB stream info url --- .../sites/chaturbate/ChaturbateModel.java | 31 ++++++++----------- .../ctbrec/sites/chaturbate/StreamInfo.java | 3 +- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java b/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java index 8f40d8dd..0f9a97e4 100644 --- a/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java +++ b/common/src/main/java/ctbrec/sites/chaturbate/ChaturbateModel.java @@ -215,7 +215,7 @@ public class ChaturbateModel extends AbstractModel { src.setBandwidth(playlist.getStreamInfo().getBandwidth()); src.setHeight(playlist.getStreamInfo().getResolution().height); src.setWidth(playlist.getStreamInfo().getResolution().width); - String masterUrl = streamInfo.url; + String masterUrl = streamInfo.hls_source; String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1); String segmentUri = baseUrl + playlist.getUri(); src.setMediaPlaylistUrl(segmentUri); @@ -299,13 +299,8 @@ public class ChaturbateModel extends AbstractModel { if (streamInfo != null && Duration.between(lastStreamInfoRequest, Instant.now()).getSeconds() < 5) { return streamInfo; } - RequestBody body = new FormBody.Builder() - .add("room_slug", getName()) - .add("bandwidth", "high") - .build(); Request req = new Request.Builder() - .url(getSite().getBaseUrl() + "/get_edge_hls_url_ajax/") - .post(body) + .url(getSite().getBaseUrl() + "/api/chatvideocontext/" + getName() + '/') .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(getSite().getBaseUrl()).getHost())) .header(X_REQUESTED_WITH, XML_HTTP_REQUEST) .build(); @@ -317,18 +312,18 @@ public class ChaturbateModel extends AbstractModel { streamInfo = mapper.readValue(content, StreamInfo.class); if (streamInfo.cmaf_edge) { - if (streamInfo.url.contains("playlist.m3u8")) { - streamInfo.url = streamInfo.url.replace("playlist.m3u8", "playlist_sfm4s.m3u8"); - } else if (streamInfo.url.contains("playlist_sfm4s.m3u8")) { - streamInfo.url = streamInfo.url.replace("playlist_sfm4s.m3u8", "playlist.m3u8"); + if (streamInfo.hls_source.contains("playlist.m3u8")) { + streamInfo.hls_source = streamInfo.hls_source.replace("playlist.m3u8", "playlist_sfm4s.m3u8"); + } else if (streamInfo.hls_source.contains("playlist_sfm4s.m3u8")) { + streamInfo.hls_source = streamInfo.hls_source.replace("playlist_sfm4s.m3u8", "playlist.m3u8"); } - var match = serverPattern.matcher(streamInfo.url); + var match = serverPattern.matcher(streamInfo.hls_source); if (getSite().getHttpClient().isLoggedIn()) { - streamInfo.url = match.replaceFirst("live-fhls/amlst"); + streamInfo.hls_source = match.replaceFirst("live-fhls/amlst"); } else { - streamInfo.url = match.replaceFirst("live-c-fhls/amlst"); + streamInfo.hls_source = match.replaceFirst("live-c-fhls/amlst"); } } @@ -343,7 +338,7 @@ public class ChaturbateModel extends AbstractModel { private int[] getResolution() throws IOException, ParseException, PlaylistException { int[] res = new int[2]; - if (!getStreamInfo().url.startsWith("http")) { + if (!getStreamInfo().hls_source.startsWith("http")) { return res; } @@ -382,10 +377,10 @@ public class ChaturbateModel extends AbstractModel { } private MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException { - log.trace("Loading master playlist {}", streamInfo.url); + log.trace("Loading master playlist {}", streamInfo.hls_source); Request req = new Request.Builder() - .url(streamInfo.url) - .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(streamInfo.url).getHost())) + .url(streamInfo.hls_source) + .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(streamInfo.hls_source).getHost())) .build(); try (Response response = getSite().getHttpClient().execute(req)) { if (response.isSuccessful()) { diff --git a/common/src/main/java/ctbrec/sites/chaturbate/StreamInfo.java b/common/src/main/java/ctbrec/sites/chaturbate/StreamInfo.java index 6b2d1a20..9530abd4 100644 --- a/common/src/main/java/ctbrec/sites/chaturbate/StreamInfo.java +++ b/common/src/main/java/ctbrec/sites/chaturbate/StreamInfo.java @@ -1,9 +1,8 @@ package ctbrec.sites.chaturbate; public class StreamInfo { - public String url; + public String hls_source; public String room_status; public String hidden_message; - public boolean success; public boolean cmaf_edge; }