Fix SC streams

This commit is contained in:
Jafea7 2025-08-31 20:09:49 +10:00
parent f28189134f
commit bc4c34307f
2 changed files with 21 additions and 18 deletions

View File

@ -22,7 +22,7 @@ import ctbrec.recorder.download.HttpHeaderFactory;
import ctbrec.recorder.download.StreamSource; import ctbrec.recorder.download.StreamSource;
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment; import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
import ctbrec.sites.Site; import ctbrec.sites.Site;
import ctbrec.sites.stripchat.StripchatModel; //import ctbrec.sites.stripchat.StripchatModel;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Request.Builder; import okhttp3.Request.Builder;
import okhttp3.Response; import okhttp3.Response;
@ -294,9 +294,9 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
if (response.isSuccessful()) { if (response.isSuccessful()) {
consecutivePlaylistTimeouts = 0; consecutivePlaylistTimeouts = 0;
String body = Objects.requireNonNull(response.body()).string(); String body = Objects.requireNonNull(response.body()).string();
if (model.getSite().getName().equalsIgnoreCase("stripchat")) { /* if (model.getSite().getName().equalsIgnoreCase("stripchat")) {
body = StripchatModel.m3uDecoder(body); body = StripchatModel.m3uDecoder(body);
} } */
if (!body.contains("#EXTINF")) { if (!body.contains("#EXTINF")) {
// no segments, empty playlist // no segments, empty playlist
return new SegmentPlaylist(segmentPlaylistUrl); return new SegmentPlaylist(segmentPlaylistUrl);

View File

@ -22,7 +22,7 @@ import org.json.JSONObject;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.security.MessageDigest; //import java.security.MessageDigest;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
@ -46,8 +46,8 @@ public class StripchatModel extends AbstractModel {
private transient Instant lastInfoRequest = Instant.EPOCH; private transient Instant lastInfoRequest = Instant.EPOCH;
// New fields for DRM fix // New fields for DRM fix
private transient String psch; // private transient String psch;
private transient String pkey; // private transient String pkey;
@Override @Override
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException { public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
@ -177,9 +177,9 @@ public class StripchatModel extends AbstractModel {
mediaUrl = mediaUrl.substring(0, mediaUrl.lastIndexOf('?')); mediaUrl = mediaUrl.substring(0, mediaUrl.lastIndexOf('?'));
} }
// Append psch & pkey if available // Append psch & pkey if available
if (psch != null && pkey != null) { /* if (psch != null && pkey != null) {
mediaUrl += "?psch=" + psch + "&pkey=" + pkey; mediaUrl += "?psch=" + psch + "&pkey=" + pkey;
} } */
src.setMediaPlaylistUrl(mediaUrl); src.setMediaPlaylistUrl(mediaUrl);
log.trace("Media playlist {}", mediaUrl); log.trace("Media playlist {}", mediaUrl);
sources.add(src); sources.add(src);
@ -198,7 +198,7 @@ public class StripchatModel extends AbstractModel {
if (response.isSuccessful()) { if (response.isSuccessful()) {
String body = response.body().string(); String body = response.body().string();
// Detect Mouflon DRM line /* // Detect Mouflon DRM line
if (body.contains("#EXT-X-MOUFLON")) { if (body.contains("#EXT-X-MOUFLON")) {
int start = body.indexOf("#EXT-X-MOUFLON:"); int start = body.indexOf("#EXT-X-MOUFLON:");
int end = body.indexOf('\n', start); int end = body.indexOf('\n', start);
@ -215,7 +215,8 @@ public class StripchatModel extends AbstractModel {
// Run through m3uDecoder // Run through m3uDecoder
String decoded = m3uDecoder(body); String decoded = m3uDecoder(body);
InputStream inputStream = new ByteArrayInputStream(decoded.getBytes(UTF_8)); InputStream inputStream = new ByteArrayInputStream(decoded.getBytes(UTF_8)); */
InputStream inputStream = new ByteArrayInputStream(body.getBytes(UTF_8));
PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8, ParsingMode.LENIENT); PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8, ParsingMode.LENIENT);
Playlist playlist = parser.parse(); Playlist playlist = parser.parse();
return playlist.getMasterPlaylist(); return playlist.getMasterPlaylist();
@ -243,15 +244,17 @@ public class StripchatModel extends AbstractModel {
log.debug("Spy start for {}", getName()); log.debug("Spy start for {}", getName());
} }
} }
String hlsUrlTemplate = "https://edge-hls.doppiocdn.com/hls/{0}{1}/master/{0}{1}_auto.m3u8?playlistType=Standart{2}"; // String hlsUrlTemplate = "https://edge-hls.doppiocdn.com/hls/{0}{1}/master/{0}{1}_auto.m3u8?playlistType=Standart{2}";
return MessageFormat.format(hlsUrlTemplate, String.valueOf(id), vrSuffix, token); String hlsUrlTemplate = "https://edge-hls.saawsedge.com/hls/{0}{1}/master/{0}{1}.m3u8";
// return MessageFormat.format(hlsUrlTemplate, String.valueOf(id), vrSuffix, token);
return MessageFormat.format(hlsUrlTemplate, String.valueOf(id), vrSuffix);
} else { } else {
throw new IOException("Playlist URL not found"); throw new IOException("Playlist URL not found");
} }
} }
// Java equivalent of Python m3u_decoder // Java equivalent of Python m3u_decoder
public static String m3uDecoder(String content) { /* public static String m3uDecoder(String content) {
List<String> decodedLines = new ArrayList<>(); List<String> decodedLines = new ArrayList<>();
String[] lines = content.split("\\r?\\n"); String[] lines = content.split("\\r?\\n");
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
@ -271,9 +274,9 @@ public class StripchatModel extends AbstractModel {
decodedLines.add(line); decodedLines.add(line);
} }
return String.join("\n", decodedLines); return String.join("\n", decodedLines);
} } */
private static String decodeMouflon(String encryptedB64, String key) throws Exception { /* private static String decodeMouflon(String encryptedB64, String key) throws Exception {
MessageDigest digest = MessageDigest.getInstance("SHA-256"); MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(key.getBytes(UTF_8)); byte[] hash = digest.digest(key.getBytes(UTF_8));
@ -292,15 +295,15 @@ public class StripchatModel extends AbstractModel {
decrypted[i] = (byte) (encrypted[i] ^ hash[i % hash.length]); decrypted[i] = (byte) (encrypted[i] ^ hash[i % hash.length]);
} }
return new String(decrypted, UTF_8); return new String(decrypted, UTF_8);
} } */
@Override @Override
public void invalidateCacheEntries() { public void invalidateCacheEntries() {
resolution = new int[]{0, 0}; resolution = new int[]{0, 0};
lastInfoRequest = Instant.EPOCH; lastInfoRequest = Instant.EPOCH;
modelInfo = null; modelInfo = null;
psch = null; // psch = null;
pkey = null; // pkey = null;
} }
@Override @Override