fix CB playlist URLs

This commit is contained in:
reusedname 2025-03-12 18:56:48 +05:00
parent cac8ee37d9
commit f8613c8817
3 changed files with 20 additions and 0 deletions

View File

@ -51,6 +51,7 @@ public abstract class HttpClient {
protected OkHttpClient client; protected OkHttpClient client;
protected Cache cache; protected Cache cache;
protected Config config; protected Config config;
@Getter
protected boolean loggedIn = false; protected boolean loggedIn = false;
protected long cacheSize; protected long cacheSize;
protected int cacheLifeTime = 600; protected int cacheLifeTime = 600;

View File

@ -30,11 +30,14 @@ import java.util.concurrent.ExecutionException;
import static ctbrec.Model.State.*; import static ctbrec.Model.State.*;
import static ctbrec.io.HttpConstants.*; import static ctbrec.io.HttpConstants.*;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.regex.Pattern;
@Slf4j @Slf4j
public class ChaturbateModel extends AbstractModel { public class ChaturbateModel extends AbstractModel {
private static final String PUBLIC = "public"; private static final String PUBLIC = "public";
private static final Pattern serverPattern = Pattern.compile("live-.+amlst");
private int[] resolution = new int[2]; private int[] resolution = new int[2];
private transient StreamInfo streamInfo; private transient StreamInfo streamInfo;
private transient Instant lastStreamInfoRequest = Instant.EPOCH; private transient Instant lastStreamInfoRequest = Instant.EPOCH;
@ -311,6 +314,21 @@ public class ChaturbateModel extends AbstractModel {
String content = response.body().string(); String content = response.body().string();
log.trace("Raw stream info for model {}: {}", getName(), content); log.trace("Raw stream info for model {}: {}", getName(), content);
streamInfo = mapper.readValue(content, StreamInfo.class); streamInfo = mapper.readValue(content, StreamInfo.class);
if (streamInfo.cmaf_edge && 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");
}
var match = serverPattern.matcher(streamInfo.url);
if (getSite().getHttpClient().isLoggedIn()) {
streamInfo.url = match.replaceFirst("live-fhls/amlst");
} else {
streamInfo.url = match.replaceFirst("live-c-fhls/amlst");
}
return streamInfo; return streamInfo;
} else { } else {
int code = response.code(); int code = response.code();

View File

@ -5,4 +5,5 @@ public class StreamInfo {
public String room_status; public String room_status;
public String hidden_message; public String hidden_message;
public boolean success; public boolean success;
public boolean cmaf_edge;
} }