Fix streamate stream source parsing

This commit is contained in:
0xboobface 2020-04-28 22:05:06 +02:00
parent d78f96fef6
commit a0d9835192
1 changed files with 2 additions and 2 deletions

View File

@ -93,6 +93,7 @@ public class StreamateModel extends AbstractModel {
try (Response response = site.getHttpClient().execute(req)) { try (Response response = site.getHttpClient().execute(req)) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
JSONObject json = new JSONObject(response.body().string()); JSONObject json = new JSONObject(response.body().string());
//LOG.debug(json.toString(2));
JSONObject formats = json.getJSONObject("formats"); JSONObject formats = json.getJSONObject("formats");
JSONObject hls = formats.getJSONObject("mp4-hls"); JSONObject hls = formats.getJSONObject("mp4-hls");
@ -110,11 +111,10 @@ public class StreamateModel extends AbstractModel {
} }
// add raw source stream // add raw source stream
if (hls.has(ORIGIN)) { if (hls.has(ORIGIN) && !hls.isNull(ORIGIN)) {
JSONObject origin = hls.getJSONObject(ORIGIN); JSONObject origin = hls.getJSONObject(ORIGIN);
StreamSource src = new StreamSource(); StreamSource src = new StreamSource();
src.mediaPlaylistUrl = origin.getString("location"); src.mediaPlaylistUrl = origin.getString("location");
origin = hls.getJSONObject(ORIGIN);
src.width = origin.optInt("videoWidth"); src.width = origin.optInt("videoWidth");
src.height = origin.optInt("videoHeight"); src.height = origin.optInt("videoHeight");
src.bandwidth = (origin.optInt("videoKbps") + origin.optInt("audioKbps")) * 1024; src.bandwidth = (origin.optInt("videoKbps") + origin.optInt("audioKbps")) * 1024;