forked from j62/ctbrec
Set thumbnail aspect ration to 9/16 for MVLive
This commit is contained in:
parent
36e5772dd5
commit
21f75fc187
|
@ -1,33 +1,12 @@
|
||||||
package ctbrec.sites.jasmin;
|
package ctbrec.sites.jasmin;
|
||||||
|
|
||||||
import static ctbrec.io.HttpConstants.*;
|
import com.iheartradio.m3u8.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.iheartradio.m3u8.Encoding;
|
|
||||||
import com.iheartradio.m3u8.Format;
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
|
||||||
import com.iheartradio.m3u8.ParsingMode;
|
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
|
||||||
import com.iheartradio.m3u8.PlaylistParser;
|
|
||||||
import com.iheartradio.m3u8.data.MasterPlaylist;
|
import com.iheartradio.m3u8.data.MasterPlaylist;
|
||||||
import com.iheartradio.m3u8.data.Playlist;
|
import com.iheartradio.m3u8.data.Playlist;
|
||||||
import com.iheartradio.m3u8.data.PlaylistData;
|
import com.iheartradio.m3u8.data.PlaylistData;
|
||||||
import com.iheartradio.m3u8.data.StreamInfo;
|
import com.iheartradio.m3u8.data.StreamInfo;
|
||||||
import com.squareup.moshi.JsonReader;
|
import com.squareup.moshi.JsonReader;
|
||||||
import com.squareup.moshi.JsonWriter;
|
import com.squareup.moshi.JsonWriter;
|
||||||
|
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
import ctbrec.StringUtil;
|
import ctbrec.StringUtil;
|
||||||
|
@ -36,10 +15,21 @@ import ctbrec.recorder.download.Download;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import static ctbrec.io.HttpConstants.*;
|
||||||
|
|
||||||
public class LiveJasminModel extends AbstractModel {
|
public class LiveJasminModel extends AbstractModel {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(LiveJasminModel.class);
|
private static final Logger LOG = LoggerFactory.getLogger(LiveJasminModel.class);
|
||||||
|
private final Random rng = new Random();
|
||||||
private String id;
|
private String id;
|
||||||
private boolean online = false;
|
private boolean online = false;
|
||||||
private int[] resolution;
|
private int[] resolution;
|
||||||
|
@ -66,7 +56,8 @@ public class LiveJasminModel extends AbstractModel {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
String body = response.body().string();
|
String body = response.body().string();
|
||||||
JSONObject json = new JSONObject(body);
|
JSONObject json = new JSONObject(body);
|
||||||
// LOG.debug(json.toString(2));
|
//LOG.debug(json.toString(2));
|
||||||
|
//Files.writeString(Path.of("/tmp/model.json"), json.toString(2));
|
||||||
if (json.optBoolean("success")) {
|
if (json.optBoolean("success")) {
|
||||||
JSONObject data = json.getJSONObject("data");
|
JSONObject data = json.getJSONObject("data");
|
||||||
JSONObject config = data.getJSONObject("config");
|
JSONObject config = data.getJSONObject("config");
|
||||||
|
@ -101,16 +92,15 @@ public class LiveJasminModel extends AbstractModel {
|
||||||
|
|
||||||
public static State mapStatus(int status) {
|
public static State mapStatus(int status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0:
|
case 0:
|
||||||
return State.OFFLINE;
|
return State.OFFLINE;
|
||||||
case 1:
|
case 1:
|
||||||
return State.ONLINE;
|
return State.ONLINE;
|
||||||
case 2:
|
case 2, 3:
|
||||||
case 3:
|
return State.PRIVATE;
|
||||||
return State.PRIVATE;
|
default:
|
||||||
default:
|
LOG.debug("Unkown state {}", status);
|
||||||
LOG.debug("Unkown state {}", status);
|
return State.UNKNOWN;
|
||||||
return State.UNKNOWN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +122,6 @@ public class LiveJasminModel extends AbstractModel {
|
||||||
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();
|
||||||
MasterPlaylist master = playlist.getMasterPlaylist();
|
MasterPlaylist master = playlist.getMasterPlaylist();
|
||||||
streamSources.clear();
|
|
||||||
for (PlaylistData playlistData : master.getPlaylists()) {
|
for (PlaylistData playlistData : master.getPlaylists()) {
|
||||||
StreamSource streamsource = new StreamSource();
|
StreamSource streamsource = new StreamSource();
|
||||||
String baseUrl = masterUrl;
|
String baseUrl = masterUrl;
|
||||||
|
@ -162,18 +151,18 @@ public class LiveJasminModel extends AbstractModel {
|
||||||
|
|
||||||
// generate a fake guest session ID
|
// generate a fake guest session ID
|
||||||
byte[] sessionIdRandom = new byte[16];
|
byte[] sessionIdRandom = new byte[16];
|
||||||
new Random().nextBytes(sessionIdRandom);
|
rng.nextBytes(sessionIdRandom);
|
||||||
String sessionId = 'g' + StringUtil.toHexString(sessionIdRandom, 32);
|
String sessionId = 'g' + StringUtil.toHexString(sessionIdRandom, 32);
|
||||||
|
|
||||||
String highResUrl = "https://api-gateway.dditsadn.com/v1/stream/performers/" + getName() + "/streams/free/formats/hls?brandId=jasmin&session=" + sessionId + "&streamName=stream_1280_720_3000";
|
String highResUrl = "https://api-gateway.dditsadn.com/v1/stream/performers/" + getName() + "/streams/free/formats/hls?brandId=jasmin&session=" + sessionId + "&streamName=stream_1280_720_3000";
|
||||||
String lowResUrl = "https://api-gateway.dditsadn.com/v1/stream/performers/" + getName() + "/streams/free/formats/hls?brandId=jasmin&session=" + sessionId + "&streamName=stream_1280_720_1953";
|
String lowResUrl = "https://api-gateway.dditsadn.com/v1/stream/performers/" + getName() + "/streams/free/formats/hls?brandId=jasmin&session=" + sessionId + "&streamName=stream_1280_720_1953";
|
||||||
|
|
||||||
String body;
|
String body;
|
||||||
try {
|
try {
|
||||||
body = getMasterPlaylistUrl(highResUrl);
|
body = getMasterPlaylistUrl(highResUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("High resolution URL not available for {}. Falling back to low res.", getName());
|
LOG.debug("High resolution URL not available for {}. Falling back to low res.", getName());
|
||||||
body= getMasterPlaylistUrl(lowResUrl);
|
body = getMasterPlaylistUrl(lowResUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject json = new JSONObject(body);
|
JSONObject json = new JSONObject(body);
|
||||||
|
@ -314,7 +303,7 @@ public class LiveJasminModel extends AbstractModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Download createDownload() {
|
public Download createDownload() {
|
||||||
if(Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
|
if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
|
||||||
return new LiveJasminHlsDownload(getSite().getHttpClient());
|
return new LiveJasminHlsDownload(getSite().getHttpClient());
|
||||||
} else {
|
} else {
|
||||||
return new LiveJasminMergedHlsDownload(getSite().getHttpClient());
|
return new LiveJasminMergedHlsDownload(getSite().getHttpClient());
|
||||||
|
|
Loading…
Reference in New Issue