forked from j62/ctbrec
1
0
Fork 0

Merge branch 'dev' into pp

This commit is contained in:
0xb00bface 2020-08-24 15:18:02 +02:00
commit 6b81ef6870
4 changed files with 56 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package ctbrec.ui.tabs; package ctbrec.ui.tabs;
import static ctbrec.Recording.State.*;
import static ctbrec.SubsequentAction.*; import static ctbrec.SubsequentAction.*;
import java.io.IOException; import java.io.IOException;
@ -561,9 +562,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
.map(JavaFxModel::new) .map(JavaFxModel::new)
.peek(fxm -> { .peek(fxm -> {
for (Recording recording : recordings) { for (Recording recording : recordings) {
if(recording.getStatus() == Recording.State.RECORDING && if(recording.getStatus() == RECORDING && Objects.equals(recording.getModel(), fxm)){
recording.getModel().getName().equals(fxm.getSanitizedNamed()))
{
fxm.getRecordingProperty().set(true); fxm.getRecordingProperty().set(true);
break; break;
} }

View File

@ -171,7 +171,7 @@ public abstract class AbstractModel implements Model {
if (getName() == null) { if (getName() == null) {
if (other.getName() != null) if (other.getName() != null)
return false; return false;
} else if (!getName().equals(other.getName())) } else if (!getSanitizedNamed().equals(other.getSanitizedNamed()))
return false; return false;
if (getUrl() == null) { if (getUrl() == null) {
if (other.getUrl() != null) if (other.getUrl() != null)

View File

@ -0,0 +1,52 @@
package ctbrec.sites.manyvids;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.io.HttpClient;
import ctbrec.recorder.download.hls.HlsDownload;
public class MVLiveHlsDownload extends HlsDownload {
private static final Logger LOG = LoggerFactory.getLogger(MVLiveMergedHlsDownload.class);
private ScheduledExecutorService scheduler;
public MVLiveHlsDownload(HttpClient client) {
super(client);
}
@Override
public void start() throws IOException {
try {
scheduler = new ScheduledThreadPoolExecutor(1, r -> {
Thread t = new Thread(r);
t.setDaemon(true);
t.setName("MVLive CF cookie updater");
t.setPriority(Thread.MIN_PRIORITY);
return t;
});
scheduler.scheduleAtFixedRate(() -> updateCloudFlareCookies(), 120, 120, TimeUnit.SECONDS);
updateCloudFlareCookies();
super.start();
} finally {
scheduler.shutdown();
}
}
private void updateCloudFlareCookies() {
try {
((MVLiveModel)getModel()).updateCloudFlareCookies();
} catch (IOException e) {
LOG.error("Couldn't update cloudflare cookies for model {}", getModel(), e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.error("Couldn't update cloudflare cookies for model {}", getModel(), e);
}
}
}

View File

@ -34,7 +34,6 @@ import ctbrec.StringUtil;
import ctbrec.io.HttpException; import ctbrec.io.HttpException;
import ctbrec.recorder.download.Download; import ctbrec.recorder.download.Download;
import ctbrec.recorder.download.StreamSource; import ctbrec.recorder.download.StreamSource;
import ctbrec.recorder.download.hls.HlsDownload;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
@ -213,7 +212,7 @@ public class MVLiveModel extends AbstractModel {
@Override @Override
public Download createDownload() { public Download createDownload() {
if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) { if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) {
return new HlsDownload(getHttpClient()); return new MVLiveHlsDownload(getHttpClient());
} else { } else {
return new MVLiveMergedHlsDownload(getHttpClient()); return new MVLiveMergedHlsDownload(getHttpClient());
} }