From c7e39fdd9827df6fb4fb2b6eac118d5a7f39f19b Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Sun, 23 Aug 2020 12:46:24 +0200 Subject: [PATCH 1/2] Fix MV Live models not showing up as recording MV Live models with spaces in the name would not show up as recording. --- client/src/main/java/ctbrec/ui/tabs/RecordedModelsTab.java | 5 ++--- common/src/main/java/ctbrec/AbstractModel.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/tabs/RecordedModelsTab.java b/client/src/main/java/ctbrec/ui/tabs/RecordedModelsTab.java index 11890010..2521d99b 100644 --- a/client/src/main/java/ctbrec/ui/tabs/RecordedModelsTab.java +++ b/client/src/main/java/ctbrec/ui/tabs/RecordedModelsTab.java @@ -1,5 +1,6 @@ package ctbrec.ui.tabs; +import static ctbrec.Recording.State.*; import static ctbrec.SubsequentAction.*; import java.io.IOException; @@ -561,9 +562,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener { .map(JavaFxModel::new) .peek(fxm -> { for (Recording recording : recordings) { - if(recording.getStatus() == Recording.State.RECORDING && - recording.getModel().getName().equals(fxm.getSanitizedNamed())) - { + if(recording.getStatus() == RECORDING && Objects.equals(recording.getModel(), fxm)){ fxm.getRecordingProperty().set(true); break; } diff --git a/common/src/main/java/ctbrec/AbstractModel.java b/common/src/main/java/ctbrec/AbstractModel.java index f87bb843..974e8380 100644 --- a/common/src/main/java/ctbrec/AbstractModel.java +++ b/common/src/main/java/ctbrec/AbstractModel.java @@ -171,7 +171,7 @@ public abstract class AbstractModel implements Model { if (getName() == null) { if (other.getName() != null) return false; - } else if (!getName().equals(other.getName())) + } else if (!getSanitizedNamed().equals(other.getSanitizedNamed())) return false; if (getUrl() == null) { if (other.getUrl() != null) From d7d3e2944b456454da803f9e56cc360f77ed7823 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xboobface@gmail.com> Date: Mon, 24 Aug 2020 15:16:45 +0200 Subject: [PATCH 2/2] Extend HlsDownload for MV Live to update the cloudflare cookies regularly --- .../sites/manyvids/MVLiveHlsDownload.java | 52 +++++++++++++++++++ .../ctbrec/sites/manyvids/MVLiveModel.java | 3 +- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/ctbrec/sites/manyvids/MVLiveHlsDownload.java diff --git a/common/src/main/java/ctbrec/sites/manyvids/MVLiveHlsDownload.java b/common/src/main/java/ctbrec/sites/manyvids/MVLiveHlsDownload.java new file mode 100644 index 00000000..de0eab83 --- /dev/null +++ b/common/src/main/java/ctbrec/sites/manyvids/MVLiveHlsDownload.java @@ -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); + } + } +} diff --git a/common/src/main/java/ctbrec/sites/manyvids/MVLiveModel.java b/common/src/main/java/ctbrec/sites/manyvids/MVLiveModel.java index 4812795b..681ddab0 100644 --- a/common/src/main/java/ctbrec/sites/manyvids/MVLiveModel.java +++ b/common/src/main/java/ctbrec/sites/manyvids/MVLiveModel.java @@ -34,7 +34,6 @@ import ctbrec.StringUtil; import ctbrec.io.HttpException; import ctbrec.recorder.download.Download; import ctbrec.recorder.download.StreamSource; -import ctbrec.recorder.download.hls.HlsDownload; import okhttp3.Request; import okhttp3.Response; @@ -213,7 +212,7 @@ public class MVLiveModel extends AbstractModel { @Override public Download createDownload() { if (Config.isServerMode() && !Config.getInstance().getSettings().recordSingleFile) { - return new HlsDownload(getHttpClient()); + return new MVLiveHlsDownload(getHttpClient()); } else { return new MVLiveMergedHlsDownload(getHttpClient()); }