forked from j62/ctbrec
Use a different way to retrieve the master playlist
@M1h43ly posted URLs in #153, which work without being logged in and even seem to support HD streams much better.
This commit is contained in:
parent
0e9ae32161
commit
9bfd15b35e
|
@ -5,6 +5,7 @@ import java.io.InputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
@ -26,6 +27,7 @@ import com.squareup.moshi.JsonWriter;
|
|||
|
||||
import ctbrec.AbstractModel;
|
||||
import ctbrec.Config;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.download.Download;
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
|
@ -48,7 +50,7 @@ public class LiveJasminModel extends AbstractModel {
|
|||
}
|
||||
|
||||
protected void loadModelInfo() throws IOException {
|
||||
String url = "https://m.livejasmin.com/en/chat-html5/" + getName();
|
||||
String url = "https://m." + LiveJasmin.baseDomain + "/en/chat-html5/" + getName();
|
||||
Request req = new Request.Builder().url(url).header("User-Agent",
|
||||
"Mozilla/5.0 (iPhone; CPU OS 10_14 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Mobile/14E304 Safari/605.1.15")
|
||||
.header("Accept", "application/json,*/*")
|
||||
|
@ -148,23 +150,31 @@ public class LiveJasminModel extends AbstractModel {
|
|||
|
||||
private String getMasterPlaylistUrl() throws IOException {
|
||||
loadModelInfo();
|
||||
String url = site.getBaseUrl() + "/en/stream/hls/free/" + getName();
|
||||
//String url = site.getBaseUrl() + "/en/stream/hls/free/" + getName();
|
||||
|
||||
// generate a fake guest session ID
|
||||
byte[] sessionIdRandom = new byte[16];
|
||||
new Random().nextBytes(sessionIdRandom);
|
||||
String sessionId = 'g' + StringUtil.toHexString(sessionIdRandom, 32);
|
||||
|
||||
String url = "https://api-gateway.dditsadn.com/v1/stream/performers/" + getName()
|
||||
+ "/streams/free/formats/hls?brandId=jasmin&session=" + sessionId + "&streamName=stream_1280_720_2000";
|
||||
LOG.debug("Getting master playlist URL from {}", url);
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("User-Agent", Config.getInstance().getSettings().httpUserAgent)
|
||||
.addHeader("User-Agent", Config.getInstance().getSettings().httpUserAgentMobile)
|
||||
.addHeader("Accept", "application/json, text/javascript, */*")
|
||||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("Referer", site.getBaseUrl())
|
||||
.addHeader("Referer", getUrl())
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
try (Response response = site.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
String body = response.body().string();
|
||||
JSONObject json = new JSONObject(body);
|
||||
if (json.optBoolean("success")) {
|
||||
if (json.has("data")) {
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
JSONObject hlsStream = data.getJSONObject("hls_stream");
|
||||
return hlsStream.getString("url");
|
||||
return data.getString("url");
|
||||
} else {
|
||||
throw new IOException("Response was not successful: " + url + "\n" + body);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue