new CB stream info url

This commit is contained in:
reusedname 2025-04-06 16:51:56 +05:00
parent c9fd95c247
commit 7a0dc3a371
2 changed files with 14 additions and 20 deletions

View File

@ -215,7 +215,7 @@ public class ChaturbateModel extends AbstractModel {
src.setBandwidth(playlist.getStreamInfo().getBandwidth()); src.setBandwidth(playlist.getStreamInfo().getBandwidth());
src.setHeight(playlist.getStreamInfo().getResolution().height); src.setHeight(playlist.getStreamInfo().getResolution().height);
src.setWidth(playlist.getStreamInfo().getResolution().width); src.setWidth(playlist.getStreamInfo().getResolution().width);
String masterUrl = streamInfo.url; String masterUrl = streamInfo.hls_source;
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1); String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);
String segmentUri = baseUrl + playlist.getUri(); String segmentUri = baseUrl + playlist.getUri();
src.setMediaPlaylistUrl(segmentUri); src.setMediaPlaylistUrl(segmentUri);
@ -299,13 +299,8 @@ public class ChaturbateModel extends AbstractModel {
if (streamInfo != null && Duration.between(lastStreamInfoRequest, Instant.now()).getSeconds() < 5) { if (streamInfo != null && Duration.between(lastStreamInfoRequest, Instant.now()).getSeconds() < 5) {
return streamInfo; return streamInfo;
} }
RequestBody body = new FormBody.Builder()
.add("room_slug", getName())
.add("bandwidth", "high")
.build();
Request req = new Request.Builder() Request req = new Request.Builder()
.url(getSite().getBaseUrl() + "/get_edge_hls_url_ajax/") .url(getSite().getBaseUrl() + "/api/chatvideocontext/" + getName() + '/')
.post(body)
.header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(getSite().getBaseUrl()).getHost())) .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(getSite().getBaseUrl()).getHost()))
.header(X_REQUESTED_WITH, XML_HTTP_REQUEST) .header(X_REQUESTED_WITH, XML_HTTP_REQUEST)
.build(); .build();
@ -317,18 +312,18 @@ public class ChaturbateModel extends AbstractModel {
streamInfo = mapper.readValue(content, StreamInfo.class); streamInfo = mapper.readValue(content, StreamInfo.class);
if (streamInfo.cmaf_edge) { if (streamInfo.cmaf_edge) {
if (streamInfo.url.contains("playlist.m3u8")) { if (streamInfo.hls_source.contains("playlist.m3u8")) {
streamInfo.url = streamInfo.url.replace("playlist.m3u8", "playlist_sfm4s.m3u8"); streamInfo.hls_source = streamInfo.hls_source.replace("playlist.m3u8", "playlist_sfm4s.m3u8");
} else if (streamInfo.url.contains("playlist_sfm4s.m3u8")) { } else if (streamInfo.hls_source.contains("playlist_sfm4s.m3u8")) {
streamInfo.url = streamInfo.url.replace("playlist_sfm4s.m3u8", "playlist.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()) { if (getSite().getHttpClient().isLoggedIn()) {
streamInfo.url = match.replaceFirst("live-fhls/amlst"); streamInfo.hls_source = match.replaceFirst("live-fhls/amlst");
} else { } 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 { private int[] getResolution() throws IOException, ParseException, PlaylistException {
int[] res = new int[2]; int[] res = new int[2];
if (!getStreamInfo().url.startsWith("http")) { if (!getStreamInfo().hls_source.startsWith("http")) {
return res; return res;
} }
@ -382,10 +377,10 @@ public class ChaturbateModel extends AbstractModel {
} }
private MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException { 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() Request req = new Request.Builder()
.url(streamInfo.url) .url(streamInfo.hls_source)
.header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(streamInfo.url).getHost())) .header(USER_AGENT, site.getHttpClient().getEffectiveUserAgent(URI.create(streamInfo.hls_source).getHost()))
.build(); .build();
try (Response response = getSite().getHttpClient().execute(req)) { try (Response response = getSite().getHttpClient().execute(req)) {
if (response.isSuccessful()) { if (response.isSuccessful()) {

View File

@ -1,9 +1,8 @@
package ctbrec.sites.chaturbate; package ctbrec.sites.chaturbate;
public class StreamInfo { public class StreamInfo {
public String url; public String hls_source;
public String room_status; public String room_status;
public String hidden_message; public String hidden_message;
public boolean success;
public boolean cmaf_edge; public boolean cmaf_edge;
} }