diff --git a/CHANGELOG.md b/CHANGELOG.md index 25a819e7..a6695e6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ======================== * Fixed MVLive recordings once again * Fix: "Check URLs" button stays inactive after the first run -* ~~Fix: recordings for some Cam4 models still didn't start~~ +* Fix: recordings for some Cam4 models still didn't start * Added "space used" to recordings tab * Added menu item to add models in paused state to the "Recording" tab * Added server setting to choose between fast and accurate playlist generation diff --git a/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java b/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java index ad0f79f3..be5da187 100644 --- a/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java +++ b/common/src/main/java/ctbrec/sites/cam4/Cam4Model.java @@ -33,6 +33,7 @@ import com.iheartradio.m3u8.data.StreamInfo; import ctbrec.AbstractModel; import ctbrec.Config; +import ctbrec.StringUtil; import ctbrec.io.HtmlParser; import ctbrec.io.HttpException; import ctbrec.recorder.download.StreamSource; @@ -53,12 +54,12 @@ public class Cam4Model extends AbstractModel { if (ignoreCache || onlineState == UNKNOWN) { try { loadModelDetails(); - LOG.info("Final playlist URL for {} {}", getName(), getPlaylistUrl()); + getPlaylistUrl(); } catch (Exception e) { onlineState = OFFLINE; } } - return onlineState == ONLINE && !privateRoom && playlistUrl != null && !playlistUrl.isEmpty(); + return onlineState == ONLINE && !privateRoom && StringUtil.isNotBlank(playlistUrl); } private void loadModelDetails() throws IOException { @@ -117,18 +118,16 @@ public class Cam4Model extends AbstractModel { } private String getPlaylistUrl() throws IOException { - if (playlistUrl == null || playlistUrl.trim().isEmpty()) { - String page = loadModelPage(); - Matcher m = Pattern.compile("hlsUrl\\s*:\\s*'(.*?)'", DOTALL | MULTILINE).matcher(page); - if (m.find()) { - playlistUrl = m.group(1); - } else { - LOG.debug("hlsURl not in page"); - getPlaylistUrlFromStreamUrl(); - } - if (playlistUrl == null) { - throw new IOException("Couldn't determine playlist url"); - } + String page = loadModelPage(); + Matcher m = Pattern.compile("hlsUrl\\s*:\\s*'(.*?)'", DOTALL | MULTILINE).matcher(page); + if (m.find()) { + playlistUrl = m.group(1); + } else { + LOG.debug("hlsUrl not in page"); + getPlaylistUrlFromStreamUrl(); + } + if (playlistUrl == null) { + throw new IOException("Couldn't determine playlist url"); } return playlistUrl; } @@ -163,15 +162,15 @@ public class Cam4Model extends AbstractModel { } private String loadModelPage() throws IOException { - Request req = new Request.Builder() + Request req = new Request.Builder() // @formatter:off .url(getUrl()) .header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent) - .header(ACCEPT, "text/html") - .header(ACCEPT_LANGUAGE, "en") + .header(ACCEPT, "*/*") + .header(ACCEPT_LANGUAGE, "*") .header(CACHE_CONTROL, NO_CACHE) .header(PRAGMA, NO_CACHE) - .header(REFERER, site.getBaseUrl()) - .build(); + .header(REFERER, getUrl()) + .build(); // @formatter:on try (Response response = site.getHttpClient().execute(req)) { if (response.isSuccessful()) { return response.body().string();