forked from j62/ctbrec
Implement FC2Live downloads for the server
This commit is contained in:
parent
16752b892c
commit
0f51be96c0
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -321,7 +321,7 @@ public class Fc2Model extends AbstractModel {
|
||||||
} else if(json.optString("name").equals("user_count") || json.optString("name").equals("comment")) {
|
} else if(json.optString("name").equals("user_count") || json.optString("name").equals("comment")) {
|
||||||
// ignore
|
// ignore
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("WS <-- {}", text);
|
LOG.debug("WS <-- {}: {}", getName(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send heartbeat every now and again
|
// send heartbeat every now and again
|
||||||
|
@ -329,7 +329,7 @@ public class Fc2Model extends AbstractModel {
|
||||||
if( (now - lastHeartBeat) > TimeUnit.SECONDS.toMillis(30)) {
|
if( (now - lastHeartBeat) > TimeUnit.SECONDS.toMillis(30)) {
|
||||||
webSocket.send("{\"name\":\"heartbeat\",\"arguments\":{},\"id\":" + messageId + "}");
|
webSocket.send("{\"name\":\"heartbeat\",\"arguments\":{},\"id\":" + messageId + "}");
|
||||||
lastHeartBeat = now;
|
lastHeartBeat = now;
|
||||||
LOG.debug("Sending heartbeat (messageId: {})", messageId);
|
LOG.debug("Sending heartbeat for {} (messageId: {})", getName(), messageId);
|
||||||
messageId++;
|
messageId++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ public class Fc2Model extends AbstractModel {
|
||||||
@Override
|
@Override
|
||||||
public Download createDownload() {
|
public Download createDownload() {
|
||||||
if(Config.isServerMode()) {
|
if(Config.isServerMode()) {
|
||||||
return super.createDownload(); // TODO implement fc2 download for server
|
return new Fc2HlsDownload(getSite().getHttpClient());
|
||||||
} else {
|
} else {
|
||||||
return new Fc2MergedHlsDownload(getSite().getHttpClient());
|
return new Fc2MergedHlsDownload(getSite().getHttpClient());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import ctbrec.sites.bonga.BongaCams;
|
||||||
import ctbrec.sites.cam4.Cam4;
|
import ctbrec.sites.cam4.Cam4;
|
||||||
import ctbrec.sites.camsoda.Camsoda;
|
import ctbrec.sites.camsoda.Camsoda;
|
||||||
import ctbrec.sites.chaturbate.Chaturbate;
|
import ctbrec.sites.chaturbate.Chaturbate;
|
||||||
|
import ctbrec.sites.fc2live.Fc2Live;
|
||||||
import ctbrec.sites.jasmin.LiveJasmin;
|
import ctbrec.sites.jasmin.LiveJasmin;
|
||||||
import ctbrec.sites.mfc.MyFreeCams;
|
import ctbrec.sites.mfc.MyFreeCams;
|
||||||
import ctbrec.sites.streamate.Streamate;
|
import ctbrec.sites.streamate.Streamate;
|
||||||
|
@ -83,6 +84,7 @@ public class HttpServer {
|
||||||
sites.add(new Cam4());
|
sites.add(new Cam4());
|
||||||
sites.add(new Camsoda());
|
sites.add(new Camsoda());
|
||||||
sites.add(new Chaturbate());
|
sites.add(new Chaturbate());
|
||||||
|
sites.add(new Fc2Live());
|
||||||
sites.add(new LiveJasmin());
|
sites.add(new LiveJasmin());
|
||||||
sites.add(new MyFreeCams());
|
sites.add(new MyFreeCams());
|
||||||
sites.add(new Streamate());
|
sites.add(new Streamate());
|
||||||
|
|
Loading…
Reference in New Issue