LIVE UPDATE FILTERING TEST FOR CHATURBATE NA

This commit is contained in:
J62 2025-03-15 14:22:09 -07:00
parent 9c1cd6b073
commit e5de6704a2
2 changed files with 31 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package ctbrec.ui.settings; package ctbrec.ui.settings;
import ctbrec.Config; import ctbrec.Config;
import ctbrec.event.Event;
import ctbrec.GlobalThreadPool; import ctbrec.GlobalThreadPool;
import ctbrec.Hmac; import ctbrec.Hmac;
import ctbrec.Settings; import ctbrec.Settings;
@ -14,6 +15,7 @@ import ctbrec.ui.SiteUI;
import ctbrec.ui.SiteUiFactory; import ctbrec.ui.SiteUiFactory;
import ctbrec.ui.controls.range.DiscreteRange; import ctbrec.ui.controls.range.DiscreteRange;
import ctbrec.ui.settings.api.*; import ctbrec.ui.settings.api.*;
import ctbrec.ui.sites.chaturbate.ChaturbateTabProvider;
import ctbrec.ui.sites.ConfigUI; import ctbrec.ui.sites.ConfigUI;
import ctbrec.ui.tabs.TabSelectionListener; import ctbrec.ui.tabs.TabSelectionListener;
import javafx.animation.FadeTransition; import javafx.animation.FadeTransition;
@ -23,6 +25,7 @@ import javafx.beans.binding.BooleanExpression;
import javafx.beans.property.*; import javafx.beans.property.*;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Node; import javafx.scene.Node;
@ -34,6 +37,7 @@ import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.util.Duration; import javafx.util.Duration;
import lombok.Getter; import lombok.Getter;
import org.controlsfx.control.spreadsheet.Grid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -210,6 +214,14 @@ public class SettingsTab extends Tab implements TabSelectionListener {
confirmationDialogs = new SimpleBooleanProperty(null, "confirmationForDangerousActions", settings.confirmationForDangerousActions); confirmationDialogs = new SimpleBooleanProperty(null, "confirmationForDangerousActions", settings.confirmationForDangerousActions);
naCamsOnly = new SimpleBooleanProperty(null, "filterNAcamsOnly", settings.filterNAcamsOnly); naCamsOnly = new SimpleBooleanProperty(null, "filterNAcamsOnly", settings.filterNAcamsOnly);
naCamsOnly.addListener((obs, oldValue, newValue) -> { settings.filterNAcamsOnly = newValue; saveConfig();}); naCamsOnly.addListener((obs, oldValue, newValue) -> { settings.filterNAcamsOnly = newValue; saveConfig();});
naCamsOnly.addListener((obs, oldValue, newValue) -> {
settings.filterNAcamsOnly = newValue;
saveConfig();
// Refresh Chaturbate tabs if the setting changes
if (getTabPane() != null) {
refreshChaturbateTabs();
}
});
useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl); useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl);
hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable); hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable);
recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched); recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched);
@ -260,7 +272,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Start minimized", startMinimized, "Start the app minimized to the tray, automatically activates \"Minimize to tray\""), Setting.of("Start minimized", startMinimized, "Start the app minimized to the tray, automatically activates \"Minimize to tray\""),
Setting.of("Add models from clipboard", monitorClipboard, "Monitor clipboard for model URLs and automatically add them to the recorder").needsRestart(), Setting.of("Add models from clipboard", monitorClipboard, "Monitor clipboard for model URLs and automatically add them to the recorder").needsRestart(),
Setting.of("Show confirmation dialogs", confirmationDialogs, "Show confirmation dialogs for irreversible actions"), Setting.of("Show confirmation dialogs", confirmationDialogs, "Show confirmation dialogs for irreversible actions"),
Setting.of("Show only North America Cams", naCamsOnly, "Show only North America Cams").needsRestart(), Setting.of("Show only North America Cams", naCamsOnly, "Show only North America Cams"),
Setting.of("Recording tab per site", recordedModelsPerSite, "Add a Recording tab for each site").needsRestart(), Setting.of("Recording tab per site", recordedModelsPerSite, "Add a Recording tab for each site").needsRestart(),
Setting.of("Check for new versions at startup", checkForUpdates, "Search for updates every startup"), Setting.of("Check for new versions at startup", checkForUpdates, "Search for updates every startup"),
Setting.of("Start Tab", startTab)), Setting.of("Start Tab", startTab)),
@ -418,6 +430,22 @@ public class SettingsTab extends Tab implements TabSelectionListener {
variablesHelpButton.disableProperty().bind(recordLocal); variablesHelpButton.disableProperty().bind(recordLocal);
} }
private void refreshChaturbateTabs() {
// Find and refresh Chaturbate tabs
ObservableList<Tab> tabs = getTabPane().getTabs();
for (Tab tab : tabs) {
if (tab.getContent() instanceof ThumbOverviewTab) {
ThumbOverviewTab overviewTab = (ThumbOverviewTab) tab.getContent();
if (overviewTab.getUpdateService() instanceof ChaturbateUpdateService) {
ChaturbateUpdateService updateService = (ChaturbateUpdateService) overviewTab.getUpdateService();
// Rebuild the URL with the updated setting
updateService.setUrl(updateService.buildUrl(updateService.getEndpoint()));
updateService.restart();
}
}
}
}
private void splitValuesChanged(ObservableValue<?> value, Object oldV, Object newV) { private void splitValuesChanged(ObservableValue<?> value, Object oldV, Object newV) {
boolean splitAfterSet = settings.splitRecordingsAfterSecs > 0; boolean splitAfterSet = settings.splitRecordingsAfterSecs > 0;
boolean splitBiggerThanSet = settings.splitRecordingsBiggerThanBytes > 0; boolean splitBiggerThanSet = settings.splitRecordingsBiggerThanBytes > 0;

View File

@ -1,6 +1,7 @@
package ctbrec.ui.sites.chaturbate; package ctbrec.ui.sites.chaturbate;
import ctbrec.Config; import ctbrec.Config;
import ctbrec.Settings;
import ctbrec.sites.chaturbate.Chaturbate; import ctbrec.sites.chaturbate.Chaturbate;
import ctbrec.ui.sites.AbstractTabProvider; import ctbrec.ui.sites.AbstractTabProvider;
import ctbrec.ui.tabs.PaginatedScheduledService; import ctbrec.ui.tabs.PaginatedScheduledService;
@ -15,12 +16,10 @@ public class ChaturbateTabProvider extends AbstractTabProvider {
private final String apiUrl; private final String apiUrl;
private final ChaturbateFollowedTab followedTab; private final ChaturbateFollowedTab followedTab;
private final boolean regionNAEnabled; // Store the setting
public ChaturbateTabProvider(Chaturbate chaturbate) { public ChaturbateTabProvider(Chaturbate chaturbate) {
super(chaturbate); super(chaturbate);
apiUrl = site.getBaseUrl() + "/api/ts"; apiUrl = site.getBaseUrl() + "/api/ts";
regionNAEnabled = Config.getInstance().isFilterNAcamsOnlyEnabled();
this.followedTab = new ChaturbateFollowedTab("Followed", buildUrl("/roomlist/room-list/?enable_recommendations=false&follow=true"), chaturbate); this.followedTab = new ChaturbateFollowedTab("Followed", buildUrl("/roomlist/room-list/?enable_recommendations=false&follow=true"), chaturbate);
} }
@ -81,6 +80,7 @@ public class ChaturbateTabProvider extends AbstractTabProvider {
// Helper function to append region filter if enabled // Helper function to append region filter if enabled
private String buildUrl(String endpoint) { private String buildUrl(String endpoint) {
boolean regionNAEnabled = Config.getInstance().isFilterNAcamsOnlyEnabled();
return apiUrl + endpoint + (regionNAEnabled ? "&regions=NA" : ""); return apiUrl + endpoint + (regionNAEnabled ? "&regions=NA" : "");
} }
} }