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
|
||||
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<>();
|
||||
for (PlaylistData playlist : masterPlaylist.getPlaylists()) {
|
||||
if (playlist.hasStreamInfo()) {
|
||||
|
@ -103,8 +117,7 @@ public class StripchatModel extends AbstractModel {
|
|||
return sources;
|
||||
}
|
||||
|
||||
private MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
||||
String url = getMasterPlaylistUrl();
|
||||
private MasterPlaylist getMasterPlaylist(String url) throws IOException, ParseException, PlaylistException {
|
||||
LOG.trace("Loading master playlist {}", url);
|
||||
Request req = new Request.Builder()
|
||||
.url(url)
|
||||
|
@ -138,7 +151,9 @@ public class StripchatModel extends AbstractModel {
|
|||
.build();
|
||||
try (Response response = site.getHttpClient().execute(req)) {
|
||||
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(""));
|
||||
JSONObject viewServers = jsonResponse.getJSONObject("viewServers");
|
||||
String serverName = viewServers.optString("flashphoner-hls");
|
||||
|
|
Loading…
Reference in New Issue