forked from j62/ctbrec
1
0
Fork 0

Implement FC2Live downloads for the server

This commit is contained in:
0xboobface 2019-01-24 20:24:09 +01:00
parent 16752b892c
commit 0f51be96c0
3 changed files with 43 additions and 3 deletions

View File

@ -0,0 +1,38 @@
package ctbrec.sites.fc2live;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.Model;
import ctbrec.io.HttpClient;
import ctbrec.recorder.download.HlsDownload;
public class Fc2HlsDownload extends HlsDownload {
private static final transient Logger LOG = LoggerFactory.getLogger(Fc2HlsDownload.class);
public Fc2HlsDownload(HttpClient client) {
super(client);
}
@Override
public void start(Model model, Config config) throws IOException {
Fc2Model fc2Model = (Fc2Model) model;
try {
fc2Model.openWebsocket();
super.start(model, config);
} catch (InterruptedException e) {
LOG.error("Couldn't start download for {}", model, e);
} finally {
fc2Model.closeWebsocket();
}
}
@Override
public void stop() {
super.stop();
}
}

View File

@ -321,7 +321,7 @@ public class Fc2Model extends AbstractModel {
} else if(json.optString("name").equals("user_count") || json.optString("name").equals("comment")) {
// ignore
} else {
LOG.debug("WS <-- {}", text);
LOG.debug("WS <-- {}: {}", getName(), text);
}
// send heartbeat every now and again
@ -329,7 +329,7 @@ public class Fc2Model extends AbstractModel {
if( (now - lastHeartBeat) > TimeUnit.SECONDS.toMillis(30)) {
webSocket.send("{\"name\":\"heartbeat\",\"arguments\":{},\"id\":" + messageId + "}");
lastHeartBeat = now;
LOG.debug("Sending heartbeat (messageId: {})", messageId);
LOG.debug("Sending heartbeat for {} (messageId: {})", getName(), messageId);
messageId++;
}
}
@ -372,7 +372,7 @@ public class Fc2Model extends AbstractModel {
@Override
public Download createDownload() {
if(Config.isServerMode()) {
return super.createDownload(); // TODO implement fc2 download for server
return new Fc2HlsDownload(getSite().getHttpClient());
} else {
return new Fc2MergedHlsDownload(getSite().getHttpClient());
}

View File

@ -32,6 +32,7 @@ import ctbrec.sites.bonga.BongaCams;
import ctbrec.sites.cam4.Cam4;
import ctbrec.sites.camsoda.Camsoda;
import ctbrec.sites.chaturbate.Chaturbate;
import ctbrec.sites.fc2live.Fc2Live;
import ctbrec.sites.jasmin.LiveJasmin;
import ctbrec.sites.mfc.MyFreeCams;
import ctbrec.sites.streamate.Streamate;
@ -83,6 +84,7 @@ public class HttpServer {
sites.add(new Cam4());
sites.add(new Camsoda());
sites.add(new Chaturbate());
sites.add(new Fc2Live());
sites.add(new LiveJasmin());
sites.add(new MyFreeCams());
sites.add(new Streamate());