Add original stream quality playlist to stream sources for Stripchat
This commit is contained in:
parent
59a5f1398e
commit
e63107cd93
|
@ -85,7 +85,21 @@ public class StripchatModel extends AbstractModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
||||||
MasterPlaylist masterPlaylist = getMasterPlaylist();
|
String url = getMasterPlaylistUrl();
|
||||||
|
MasterPlaylist masterPlaylist = getMasterPlaylist(url);
|
||||||
|
List<StreamSource> streamSources = extractStreamSources(masterPlaylist);
|
||||||
|
try {
|
||||||
|
String originalUrl = url.replace("_auto", "");
|
||||||
|
masterPlaylist = getMasterPlaylist(originalUrl);
|
||||||
|
List<StreamSource> originalStreamSource = extractStreamSources(masterPlaylist);
|
||||||
|
streamSources.addAll(originalStreamSource);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Original stream quality not available", e);
|
||||||
|
}
|
||||||
|
return streamSources;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<StreamSource> extractStreamSources(MasterPlaylist masterPlaylist) {
|
||||||
List<StreamSource> sources = new ArrayList<>();
|
List<StreamSource> sources = new ArrayList<>();
|
||||||
for (PlaylistData playlist : masterPlaylist.getPlaylists()) {
|
for (PlaylistData playlist : masterPlaylist.getPlaylists()) {
|
||||||
if (playlist.hasStreamInfo()) {
|
if (playlist.hasStreamInfo()) {
|
||||||
|
@ -103,8 +117,7 @@ public class StripchatModel extends AbstractModel {
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
private MasterPlaylist getMasterPlaylist(String url) throws IOException, ParseException, PlaylistException {
|
||||||
String url = getMasterPlaylistUrl();
|
|
||||||
LOG.trace("Loading master playlist {}", url);
|
LOG.trace("Loading master playlist {}", url);
|
||||||
Request req = new Request.Builder()
|
Request req = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
|
@ -138,7 +151,9 @@ public class StripchatModel extends AbstractModel {
|
||||||
.build();
|
.build();
|
||||||
try (Response response = site.getHttpClient().execute(req)) {
|
try (Response response = site.getHttpClient().execute(req)) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
JSONObject jsonResponse = new JSONObject(response.body().string());
|
String body = response.body().string();
|
||||||
|
LOG.trace(body);
|
||||||
|
JSONObject jsonResponse = new JSONObject(body);
|
||||||
String streamName = jsonResponse.optString("streamName", jsonResponse.optString(""));
|
String streamName = jsonResponse.optString("streamName", jsonResponse.optString(""));
|
||||||
JSONObject viewServers = jsonResponse.getJSONObject("viewServers");
|
JSONObject viewServers = jsonResponse.getJSONObject("viewServers");
|
||||||
String serverName = viewServers.optString("flashphoner-hls");
|
String serverName = viewServers.optString("flashphoner-hls");
|
||||||
|
|
Loading…
Reference in New Issue