Improve error handling for webrtc streams for cherry.tv
This commit is contained in:
parent
15593cd9b8
commit
8004915125
|
@ -0,0 +1,7 @@
|
|||
package ctbrec;
|
||||
|
||||
public class StreamNotFoundException extends RuntimeException {
|
||||
public StreamNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
|
@ -6,10 +6,7 @@ import com.iheartradio.m3u8.data.Playlist;
|
|||
import com.iheartradio.m3u8.data.PlaylistData;
|
||||
import com.squareup.moshi.JsonReader;
|
||||
import com.squareup.moshi.JsonWriter;
|
||||
import ctbrec.AbstractModel;
|
||||
import ctbrec.Config;
|
||||
import ctbrec.NotImplementedExcetion;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.*;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
import okhttp3.MediaType;
|
||||
|
@ -30,7 +27,8 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import static ctbrec.ErrorMessages.HTTP_RESPONSE_BODY_IS_NULL;
|
||||
import static ctbrec.Model.State.*;
|
||||
import static ctbrec.Model.State.OFFLINE;
|
||||
import static ctbrec.Model.State.ONLINE;
|
||||
import static ctbrec.io.HttpConstants.*;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
|
@ -79,6 +77,7 @@ public class CherryTvModel extends AbstractModel {
|
|||
for (Iterator<String> iter = apolloState.keys(); iter.hasNext(); ) {
|
||||
String key = iter.next();
|
||||
if (key.startsWith("Broadcast:")) {
|
||||
LOG.trace("Model properties:\n{}", apolloState.toString(2));
|
||||
JSONObject broadcast = apolloState.getJSONObject(key);
|
||||
setDisplayName(broadcast.optString("title"));
|
||||
online = broadcast.optString("showStatus").equalsIgnoreCase("Public")
|
||||
|
@ -146,6 +145,10 @@ public class CherryTvModel extends AbstractModel {
|
|||
}
|
||||
|
||||
private MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
||||
if (masterPlaylistUrl == null) {
|
||||
LOG.info("Master playlist not found for {}:{}. This probably is webrtc stream", getSite().getName(), getName());
|
||||
throw new StreamNotFoundException("Webrtc streams are not supported for " + getSite().getName());
|
||||
}
|
||||
LOG.trace("Loading master playlist {}", masterPlaylistUrl);
|
||||
Request req = new Request.Builder()
|
||||
.url(masterPlaylistUrl)
|
||||
|
@ -275,23 +278,6 @@ public class CherryTvModel extends AbstractModel {
|
|||
.build();
|
||||
}
|
||||
|
||||
public void mapOnlineState(String roomState) {
|
||||
switch (roomState) {
|
||||
case "private":
|
||||
case "fullprivate":
|
||||
setOnlineState(PRIVATE);
|
||||
break;
|
||||
case "group":
|
||||
case "public":
|
||||
setOnlineState(ONLINE);
|
||||
setOnline(true);
|
||||
break;
|
||||
default:
|
||||
LOG.debug(roomState);
|
||||
setOnlineState(OFFLINE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue