WinkRU SC and SR fixes

This commit is contained in:
jafea7 2025-03-24 23:08:57 +11:00 committed by Jafea7
parent d95c633326
commit 1732da292f
4 changed files with 59 additions and 6 deletions

View File

@ -80,6 +80,11 @@
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId> <artifactId>jetty-servlet</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-webp</artifactId>
<version>3.10.1</version>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>

View File

@ -27,7 +27,7 @@ public abstract class AbstractStreamrayUpdateService extends PaginatedScheduledS
protected String getPreviewURL(String name) { protected String getPreviewURL(String name) {
String lname = name.toLowerCase(); String lname = name.toLowerCase();
String url = MessageFormat.format("https://images4.streamray.com/images/streamray/won/jpg/{0}/{1}/{2}_640.jpg", lname.substring(0, 1), lname.substring(lname.length() - 1), lname); String url = MessageFormat.format("https://s3root.prod.cams.run/cams-d-com-production-model-snapshot/won/jpg/{0}/{1}/{2}.jpg", lname.substring(0,1), lname.substring(lname.length()-1), lname);
try { try {
return MessageFormat.format("https://dynimages.securedataimages.com/unsigned/rs:fill:640::0/g:no/plain/{0}@jpg", URLEncoder.encode(url, UTF_8)); return MessageFormat.format("https://dynimages.securedataimages.com/unsigned/rs:fill:640::0/g:no/plain/{0}@jpg", URLEncoder.encode(url, UTF_8));
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -47,6 +47,7 @@ import javafx.scene.shape.Shape;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment; import javafx.scene.text.TextAlignment;
import javafx.util.Duration; import javafx.util.Duration;
import javafx.embed.swing.SwingFXUtils;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -61,6 +62,9 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import static ctbrec.Model.State.OFFLINE; import static ctbrec.Model.State.OFFLINE;
import static ctbrec.Model.State.ONLINE; import static ctbrec.Model.State.ONLINE;
import static ctbrec.io.HttpConstants.*; import static ctbrec.io.HttpConstants.*;
@ -434,7 +438,8 @@ public class ThumbCell extends StackPane {
double width = 480; double width = 480;
double height = width * imgAspectRatio; double height = width * imgAspectRatio;
InputStream bodyStream = Objects.requireNonNull(resp.body(), "HTTP body is null").byteStream(); InputStream bodyStream = Objects.requireNonNull(resp.body(), "HTTP body is null").byteStream();
var img = new Image(bodyStream, width, height, preserveAspectRatio.get(), true); BufferedImage bimg = ImageIO.read(bodyStream);
Image img = SwingFXUtils.toFXImage(bimg, null);
if (img.progressProperty().get() == 1.0) { if (img.progressProperty().get() == 1.0) {
Platform.runLater(() -> { Platform.runLater(() -> {
iv.setImage(img); iv.setImage(img);

View File

@ -27,11 +27,14 @@ import java.time.LocalDate;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.net.URLEncoder;
import static ctbrec.Model.State.*; import static ctbrec.Model.State.*;
import static ctbrec.io.HttpConstants.*; import static ctbrec.io.HttpConstants.*;
import static ctbrec.sites.streamray.Streamray.API_URL; import static ctbrec.sites.streamray.Streamray.API_URL;
import static java.nio.charset.StandardCharsets.UTF_8;
@Slf4j @Slf4j
public class StreamrayModel extends AbstractModel { public class StreamrayModel extends AbstractModel {
@ -52,6 +55,9 @@ public class StreamrayModel extends AbstractModel {
private transient JSONObject modelInfo; private transient JSONObject modelInfo;
private transient Instant lastInfoRequest = Instant.EPOCH; private transient Instant lastInfoRequest = Instant.EPOCH;
private transient JSONObject apiInfo;
private transient Instant lastApiRequest = Instant.EPOCH;
@Override @Override
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException { public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
if (ignoreCache) { if (ignoreCache) {
@ -101,10 +107,45 @@ public class StreamrayModel extends AbstractModel {
} }
private String getMasterPlaylistUrl() throws IOException { private String getMasterPlaylistUrl() throws IOException {
JSONObject json = getModelInfo();
String mpp = json.getString("mpp");
String lname = getName().toLowerCase(); String lname = getName().toLowerCase();
return MessageFormat.format("https://stream14.cams.com/h5live/http/playlist.m3u8?url=rtmp%3A%2F%2F{0}%3A1935%2Fcams%2F{1}%3Fcams%2F{1}_720p&stream={2}", mpp, lname, getName()); JSONObject apiInfo = getApiInfo();
if (apiInfo.has("origin")) {
String origin = apiInfo.optString("origin");
String appName = apiInfo.optString("applicationName", "origin");
String token = apiInfo.optString("token");
String streamUrl = MessageFormat.format("rtmp://{0}:1935/{1}/{2}?token={3}&site=cams.com", origin, appName, lname, token);
String streamName = lname;
if (appName.equals("webrtc")) {
streamName = lname + "_720p";
}
String playlistURL = MessageFormat.format("https://stream14cdn.securedataimages.com/h5live/http/playlist.m3u8?url={0}&stream={1}", URLEncoder.encode(streamUrl, UTF_8), URLEncoder.encode(streamName, UTF_8));
return playlistURL;
} else {
throw new IOException("Can not get master playlist url");
}
}
private JSONObject getApiInfo() throws IOException {
if (Objects.nonNull(apiInfo) && Duration.between(lastApiRequest, Instant.now()).getSeconds() < 5) {
return apiInfo;
}
lastApiRequest = Instant.now();
String url = MessageFormat.format(API_URL + "/broadcasting/api/urls/anonymous/{0}/", URLEncoder.encode(getName().toLowerCase(), UTF_8));
Request req = new Request.Builder().url(url)
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
.header(ACCEPT_LANGUAGE, "en")
.header(ORIGIN, getSite().getBaseUrl())
.header(REFERER, getSite().getBaseUrl() + '/' + getName())
.build();
try (Response response = site.getHttpClient().execute(req)) {
if (response.isSuccessful()) {
JSONObject jsonResponse = new JSONObject(response.body().string());
apiInfo = jsonResponse;
return apiInfo;
} else {
throw new HttpException(response.code(), response.message());
}
}
} }
@Override @Override
@ -157,7 +198,7 @@ public class StreamrayModel extends AbstractModel {
@Override @Override
public RecordingProcess createDownload() { public RecordingProcess createDownload() {
return new FfmpegHlsDownload(getSite().getHttpClient()); return new FfmpegHlsDownload(new StreamrayHttpClient(Config.getInstance()));
} }
@Override @Override
@ -238,6 +279,8 @@ public class StreamrayModel extends AbstractModel {
status = null; status = null;
lastInfoRequest = Instant.EPOCH; lastInfoRequest = Instant.EPOCH;
modelInfo = null; modelInfo = null;
lastApiRequest = Instant.EPOCH;
apiInfo = null;
} }
public boolean isNew() { public boolean isNew() {