Set thumbnail aspect ration to 9/16 for MVLive

This commit is contained in:
0xb00bface 2022-05-07 18:50:45 +02:00
parent 36e5772dd5
commit 21f75fc187
1 changed files with 27 additions and 38 deletions

View File

@ -1,33 +1,12 @@
package ctbrec.sites.jasmin;
import static ctbrec.io.HttpConstants.*;
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.*;
import com.iheartradio.m3u8.data.MasterPlaylist;
import com.iheartradio.m3u8.data.Playlist;
import com.iheartradio.m3u8.data.PlaylistData;
import com.iheartradio.m3u8.data.StreamInfo;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
import ctbrec.AbstractModel;
import ctbrec.Config;
import ctbrec.StringUtil;
@ -36,10 +15,21 @@ import ctbrec.recorder.download.Download;
import ctbrec.recorder.download.StreamSource;
import okhttp3.Request;
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 {
private static final Logger LOG = LoggerFactory.getLogger(LiveJasminModel.class);
private final Random rng = new Random();
private String id;
private boolean online = false;
private int[] resolution;
@ -66,7 +56,8 @@ public class LiveJasminModel extends AbstractModel {
if (response.isSuccessful()) {
String body = response.body().string();
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")) {
JSONObject data = json.getJSONObject("data");
JSONObject config = data.getJSONObject("config");
@ -101,16 +92,15 @@ public class LiveJasminModel extends AbstractModel {
public static State mapStatus(int status) {
switch (status) {
case 0:
return State.OFFLINE;
case 1:
return State.ONLINE;
case 2:
case 3:
return State.PRIVATE;
default:
LOG.debug("Unkown state {}", status);
return State.UNKNOWN;
case 0:
return State.OFFLINE;
case 1:
return State.ONLINE;
case 2, 3:
return State.PRIVATE;
default:
LOG.debug("Unkown state {}", status);
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);
Playlist playlist = parser.parse();
MasterPlaylist master = playlist.getMasterPlaylist();
streamSources.clear();
for (PlaylistData playlistData : master.getPlaylists()) {
StreamSource streamsource = new StreamSource();
String baseUrl = masterUrl;
@ -162,18 +151,18 @@ public class LiveJasminModel extends AbstractModel {
// generate a fake guest session ID
byte[] sessionIdRandom = new byte[16];
new Random().nextBytes(sessionIdRandom);
rng.nextBytes(sessionIdRandom);
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 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;
try {
body = getMasterPlaylistUrl(highResUrl);
} catch (Exception e) {
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);
@ -314,7 +303,7 @@ public class LiveJasminModel extends AbstractModel {
@Override
public Download createDownload() {
if(Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
return new LiveJasminHlsDownload(getSite().getHttpClient());
} else {
return new LiveJasminMergedHlsDownload(getSite().getHttpClient());