forked from j62/ctbrec
Try to log in on startup
Maybe we have to change this in the future so that the server logs in on a regular basis.
This commit is contained in:
parent
3958a7b5f1
commit
5e46933905
|
@ -95,6 +95,7 @@ public class HttpServer {
|
||||||
for (Site site : sites) {
|
for (Site site : sites) {
|
||||||
if (site.isEnabled()) {
|
if (site.isEnabled()) {
|
||||||
site.init();
|
site.init();
|
||||||
|
safeLogin(site);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onlineMonitor = new OnlineMonitor(recorder);
|
onlineMonitor = new OnlineMonitor(recorder);
|
||||||
|
@ -102,6 +103,21 @@ public class HttpServer {
|
||||||
startHttpServer();
|
startHttpServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void safeLogin(Site site) {
|
||||||
|
if (site.credentialsAvailable()) {
|
||||||
|
try {
|
||||||
|
boolean success = site.login();
|
||||||
|
if (success) {
|
||||||
|
LOG.info("Successfully logged in to {}", site.getName());
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Login returned false");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.info("Login to {} failed", site.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void createSites() {
|
private void createSites() {
|
||||||
sites.add(new BongaCams());
|
sites.add(new BongaCams());
|
||||||
sites.add(new Cam4());
|
sites.add(new Cam4());
|
||||||
|
|
Loading…
Reference in New Issue