fix CB playlist URLs
This commit is contained in:
parent
cac8ee37d9
commit
f8613c8817
|
@ -51,6 +51,7 @@ public abstract class HttpClient {
|
|||
protected OkHttpClient client;
|
||||
protected Cache cache;
|
||||
protected Config config;
|
||||
@Getter
|
||||
protected boolean loggedIn = false;
|
||||
protected long cacheSize;
|
||||
protected int cacheLifeTime = 600;
|
||||
|
|
|
@ -30,11 +30,14 @@ import java.util.concurrent.ExecutionException;
|
|||
import static ctbrec.Model.State.*;
|
||||
import static ctbrec.io.HttpConstants.*;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
public class ChaturbateModel extends AbstractModel {
|
||||
|
||||
private static final String PUBLIC = "public";
|
||||
private static final Pattern serverPattern = Pattern.compile("live-.+amlst");
|
||||
|
||||
private int[] resolution = new int[2];
|
||||
private transient StreamInfo streamInfo;
|
||||
private transient Instant lastStreamInfoRequest = Instant.EPOCH;
|
||||
|
@ -311,6 +314,21 @@ public class ChaturbateModel extends AbstractModel {
|
|||
String content = response.body().string();
|
||||
log.trace("Raw stream info for model {}: {}", getName(), content);
|
||||
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;
|
||||
} else {
|
||||
int code = response.code();
|
||||
|
|
|
@ -5,4 +5,5 @@ public class StreamInfo {
|
|||
public String room_status;
|
||||
public String hidden_message;
|
||||
public boolean success;
|
||||
public boolean cmaf_edge;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue