Use a different URL to fetch the stream info for Chaturbate
This commit is contained in:
parent
4946d0161a
commit
9c8fe1f89c
|
@ -81,7 +81,7 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resolution = getResolution();
|
resolution = getResolution();
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ExecutionException(e);
|
throw new ExecutionException(e);
|
||||||
}
|
}
|
||||||
return resolution;
|
return resolution;
|
||||||
|
@ -164,7 +164,6 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
||||||
try {
|
|
||||||
streamInfo = loadStreamInfo();
|
streamInfo = loadStreamInfo();
|
||||||
MasterPlaylist masterPlaylist = getMasterPlaylist();
|
MasterPlaylist masterPlaylist = getMasterPlaylist();
|
||||||
List<StreamSource> sources = new ArrayList<>();
|
List<StreamSource> sources = new ArrayList<>();
|
||||||
|
@ -173,7 +172,7 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
StreamSource src = new StreamSource();
|
StreamSource src = new StreamSource();
|
||||||
src.bandwidth = playlist.getStreamInfo().getBandwidth();
|
src.bandwidth = playlist.getStreamInfo().getBandwidth();
|
||||||
src.height = playlist.getStreamInfo().getResolution().height;
|
src.height = playlist.getStreamInfo().getResolution().height;
|
||||||
String masterUrl = streamInfo.url;
|
String masterUrl = streamInfo.hls_source;
|
||||||
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);
|
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);
|
||||||
String segmentUri = baseUrl + playlist.getUri();
|
String segmentUri = baseUrl + playlist.getUri();
|
||||||
src.mediaPlaylistUrl = segmentUri;
|
src.mediaPlaylistUrl = segmentUri;
|
||||||
|
@ -185,10 +184,6 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sources;
|
return sources;
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
throw new ExecutionException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -245,12 +240,12 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StreamInfo getStreamInfo() throws IOException, InterruptedException {
|
private StreamInfo getStreamInfo() throws IOException {
|
||||||
return getStreamInfo(false);
|
return getStreamInfo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StreamInfo getStreamInfo(boolean failFast) throws IOException, InterruptedException {
|
private StreamInfo getStreamInfo(boolean failFast) throws IOException {
|
||||||
if(failFast) {
|
if (failFast) {
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
} else {
|
} else {
|
||||||
return Optional.ofNullable(streamInfo).orElse(loadStreamInfo());
|
return Optional.ofNullable(streamInfo).orElse(loadStreamInfo());
|
||||||
|
@ -261,13 +256,8 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
if (Duration.between(lastStreamInfoRequest, Instant.now()).getSeconds() < 2) {
|
if (Duration.between(lastStreamInfoRequest, Instant.now()).getSeconds() < 2) {
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
}
|
}
|
||||||
RequestBody body = new FormBody.Builder()
|
|
||||||
.add("room_slug", getName())
|
|
||||||
.add("bandwidth", "high")
|
|
||||||
.build();
|
|
||||||
Request req = new Request.Builder()
|
Request req = new Request.Builder()
|
||||||
.url(getSite().getBaseUrl() + "/get_edge_hls_url_ajax/")
|
.url(getSite().getBaseUrl() + "/api/chatvideocontext/" + getName() + '/')
|
||||||
.post(body)
|
|
||||||
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
||||||
.header(X_REQUESTED_WITH, XML_HTTP_REQUEST)
|
.header(X_REQUESTED_WITH, XML_HTTP_REQUEST)
|
||||||
.build();
|
.build();
|
||||||
|
@ -288,9 +278,10 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getResolution() throws IOException, ParseException, PlaylistException, InterruptedException {
|
private int[] getResolution() throws IOException, ParseException, PlaylistException {
|
||||||
int[] res = new int[2];
|
int[] res = new int[2];
|
||||||
if(!getStreamInfo().url.startsWith("http")) {
|
String url = Optional.ofNullable(getStreamInfo().hls_source).orElse("");
|
||||||
|
if(!url.startsWith("http")) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,14 +315,14 @@ public class ChaturbateModel extends AbstractModel { // NOSONAR
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException, InterruptedException {
|
public MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
||||||
return getMasterPlaylist(getStreamInfo());
|
return getMasterPlaylist(getStreamInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException {
|
private MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException {
|
||||||
LOG.trace("Loading master playlist {}", streamInfo.url);
|
LOG.trace("Loading master playlist {}", streamInfo.hls_source);
|
||||||
Request req = new Request.Builder()
|
Request req = new Request.Builder()
|
||||||
.url(streamInfo.url)
|
.url(streamInfo.hls_source)
|
||||||
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
||||||
.build();
|
.build();
|
||||||
try (Response response = getSite().getHttpClient().execute(req)) {
|
try (Response response = getSite().getHttpClient().execute(req)) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package ctbrec.sites.chaturbate;
|
package ctbrec.sites.chaturbate;
|
||||||
|
|
||||||
public class StreamInfo {
|
public class StreamInfo {
|
||||||
public String url;
|
public String hls_source;
|
||||||
public String room_status;
|
public String room_status;
|
||||||
public String hidden_message;
|
public String hidden_message;
|
||||||
public boolean success;
|
public boolean success;
|
||||||
|
|
Loading…
Reference in New Issue