Update playlist all the time
Before the playlist was only retrieved, when it was empty (on the initial call). Now the playlist is updated every time.
This commit is contained in:
parent
43d8b9d2de
commit
8fe48f91b7
|
@ -2,7 +2,7 @@
|
||||||
========================
|
========================
|
||||||
* Fixed MVLive recordings once again
|
* Fixed MVLive recordings once again
|
||||||
* Fix: "Check URLs" button stays inactive after the first run
|
* 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 "space used" to recordings tab
|
||||||
* Added menu item to add models in paused state to the "Recording" 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
|
* Added server setting to choose between fast and accurate playlist generation
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.iheartradio.m3u8.data.StreamInfo;
|
||||||
|
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
import ctbrec.Config;
|
import ctbrec.Config;
|
||||||
|
import ctbrec.StringUtil;
|
||||||
import ctbrec.io.HtmlParser;
|
import ctbrec.io.HtmlParser;
|
||||||
import ctbrec.io.HttpException;
|
import ctbrec.io.HttpException;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
|
@ -53,12 +54,12 @@ public class Cam4Model extends AbstractModel {
|
||||||
if (ignoreCache || onlineState == UNKNOWN) {
|
if (ignoreCache || onlineState == UNKNOWN) {
|
||||||
try {
|
try {
|
||||||
loadModelDetails();
|
loadModelDetails();
|
||||||
LOG.info("Final playlist URL for {} {}", getName(), getPlaylistUrl());
|
getPlaylistUrl();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
onlineState = OFFLINE;
|
onlineState = OFFLINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return onlineState == ONLINE && !privateRoom && playlistUrl != null && !playlistUrl.isEmpty();
|
return onlineState == ONLINE && !privateRoom && StringUtil.isNotBlank(playlistUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadModelDetails() throws IOException {
|
private void loadModelDetails() throws IOException {
|
||||||
|
@ -117,19 +118,17 @@ public class Cam4Model extends AbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPlaylistUrl() throws IOException {
|
private String getPlaylistUrl() throws IOException {
|
||||||
if (playlistUrl == null || playlistUrl.trim().isEmpty()) {
|
|
||||||
String page = loadModelPage();
|
String page = loadModelPage();
|
||||||
Matcher m = Pattern.compile("hlsUrl\\s*:\\s*'(.*?)'", DOTALL | MULTILINE).matcher(page);
|
Matcher m = Pattern.compile("hlsUrl\\s*:\\s*'(.*?)'", DOTALL | MULTILINE).matcher(page);
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
playlistUrl = m.group(1);
|
playlistUrl = m.group(1);
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("hlsURl not in page");
|
LOG.debug("hlsUrl not in page");
|
||||||
getPlaylistUrlFromStreamUrl();
|
getPlaylistUrlFromStreamUrl();
|
||||||
}
|
}
|
||||||
if (playlistUrl == null) {
|
if (playlistUrl == null) {
|
||||||
throw new IOException("Couldn't determine playlist url");
|
throw new IOException("Couldn't determine playlist url");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return playlistUrl;
|
return playlistUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,15 +162,15 @@ public class Cam4Model extends AbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String loadModelPage() throws IOException {
|
private String loadModelPage() throws IOException {
|
||||||
Request req = new Request.Builder()
|
Request req = new Request.Builder() // @formatter:off
|
||||||
.url(getUrl())
|
.url(getUrl())
|
||||||
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
.header(USER_AGENT, Config.getInstance().getSettings().httpUserAgent)
|
||||||
.header(ACCEPT, "text/html")
|
.header(ACCEPT, "*/*")
|
||||||
.header(ACCEPT_LANGUAGE, "en")
|
.header(ACCEPT_LANGUAGE, "*")
|
||||||
.header(CACHE_CONTROL, NO_CACHE)
|
.header(CACHE_CONTROL, NO_CACHE)
|
||||||
.header(PRAGMA, NO_CACHE)
|
.header(PRAGMA, NO_CACHE)
|
||||||
.header(REFERER, site.getBaseUrl())
|
.header(REFERER, getUrl())
|
||||||
.build();
|
.build(); // @formatter:on
|
||||||
try (Response response = site.getHttpClient().execute(req)) {
|
try (Response response = site.getHttpClient().execute(req)) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
return response.body().string();
|
return response.body().string();
|
||||||
|
|
Loading…
Reference in New Issue