forked from j62/ctbrec
Convert ignore list in a list of URLs to save space
This commit is contained in:
parent
0e014f8d8d
commit
924c60fb0e
|
@ -1,6 +1,9 @@
|
||||||
4.1.2
|
4.1.2
|
||||||
========================
|
========================
|
||||||
* Fixed bug, which caused recordings to get stuck
|
* Fixed bug, which caused recordings to get stuck
|
||||||
|
* Ignore list is now saved as URLs only. The old format is not compatible
|
||||||
|
anymore, so make sure, that you export them again, if you created a backup
|
||||||
|
before.
|
||||||
|
|
||||||
4.1.1
|
4.1.1
|
||||||
========================
|
========================
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class IgnoreModelsAction {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
for (Model model : selectedModels) {
|
for (Model model : selectedModels) {
|
||||||
Model modelToIgnore = unwrap(model);
|
Model modelToIgnore = unwrap(model);
|
||||||
settings.modelsIgnored.add(modelToIgnore);
|
settings.ignoredModels.add(modelToIgnore.getUrl());
|
||||||
}
|
}
|
||||||
if (withRemoveDialog) {
|
if (withRemoveDialog) {
|
||||||
boolean removeAsWell = Dialogs.showConfirmDialog("Ignore Model", null, "Remove as well?", source.getScene());
|
boolean removeAsWell = Dialogs.showConfirmDialog("Ignore Model", null, "Remove as well?", source.getScene());
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class IgnoreList extends GridPane {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(IgnoreList.class);
|
private static final Logger LOG = LoggerFactory.getLogger(IgnoreList.class);
|
||||||
|
|
||||||
private ListView<Model> ignoreListView;
|
private ListView<String> ignoreListView;
|
||||||
|
|
||||||
private List<Site> sites;
|
private List<Site> sites;
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ public class IgnoreList extends GridPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeSelectedModels() {
|
private void removeSelectedModels() {
|
||||||
List<Model> selectedModels = ignoreListView.getSelectionModel().getSelectedItems();
|
List<String> selectedModels = ignoreListView.getSelectionModel().getSelectedItems();
|
||||||
if (selectedModels.isEmpty()) {
|
if (selectedModels.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Config.getInstance().getSettings().modelsIgnored.removeAll(selectedModels);
|
Config.getInstance().getSettings().ignoredModels.removeAll(selectedModels);
|
||||||
ignoreListView.getItems().removeAll(selectedModels);
|
ignoreListView.getItems().removeAll(selectedModels);
|
||||||
LOG.debug(Config.getInstance().getSettings().modelsIgnored.toString());
|
LOG.debug(Config.getInstance().getSettings().ignoredModels.toString());
|
||||||
try {
|
try {
|
||||||
Config.getInstance().save();
|
Config.getInstance().save();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -99,7 +99,7 @@ public class IgnoreList extends GridPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadIgnoredModels() {
|
private void loadIgnoredModels() {
|
||||||
List<Model> ignored = Config.getInstance().getSettings().modelsIgnored;
|
List<String> ignored = Config.getInstance().getSettings().ignoredModels;
|
||||||
ignoreListView.getItems().clear();
|
ignoreListView.getItems().clear();
|
||||||
ignoreListView.getItems().addAll(ignored);
|
ignoreListView.getItems().addAll(ignored);
|
||||||
Collections.sort(ignoreListView.getItems());
|
Collections.sort(ignoreListView.getItems());
|
||||||
|
@ -116,11 +116,11 @@ public class IgnoreList extends GridPane {
|
||||||
File file = chooser.showSaveDialog(null);
|
File file = chooser.showSaveDialog(null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
Moshi moshi = new Moshi.Builder().add(Model.class, new ModelJsonAdapter(sites)).build();
|
Moshi moshi = new Moshi.Builder().add(Model.class, new ModelJsonAdapter(sites)).build();
|
||||||
Type modelListType = Types.newParameterizedType(List.class, Model.class);
|
Type modelListType = Types.newParameterizedType(List.class, String.class);
|
||||||
JsonAdapter<List<Model>> adapter = moshi.adapter(modelListType);
|
JsonAdapter<List<String>> adapter = moshi.adapter(modelListType);
|
||||||
adapter = adapter.indent(" ");
|
adapter = adapter.indent(" ");
|
||||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||||
String json = adapter.toJson(Config.getInstance().getSettings().modelsIgnored);
|
String json = adapter.toJson(Config.getInstance().getSettings().ignoredModels);
|
||||||
out.write(json.getBytes(StandardCharsets.UTF_8));
|
out.write(json.getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Dialogs.showError(getScene(), "Couldn't export ignore list", e.getLocalizedMessage(), e);
|
Dialogs.showError(getScene(), "Couldn't export ignore list", e.getLocalizedMessage(), e);
|
||||||
|
@ -134,13 +134,13 @@ public class IgnoreList extends GridPane {
|
||||||
File file = chooser.showOpenDialog(null);
|
File file = chooser.showOpenDialog(null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
Moshi moshi = new Moshi.Builder().add(Model.class, new ModelJsonAdapter(sites)).build();
|
Moshi moshi = new Moshi.Builder().add(Model.class, new ModelJsonAdapter(sites)).build();
|
||||||
Type modelListType = Types.newParameterizedType(List.class, Model.class);
|
Type modelListType = Types.newParameterizedType(List.class, String.class);
|
||||||
JsonAdapter<List<Model>> adapter = moshi.adapter(modelListType);
|
JsonAdapter<List<String>> adapter = moshi.adapter(modelListType);
|
||||||
try {
|
try {
|
||||||
byte[] fileContent = Files.readAllBytes(file.toPath());
|
byte[] fileContent = Files.readAllBytes(file.toPath());
|
||||||
List<Model> ignoredModels = adapter.fromJson(new String(fileContent, StandardCharsets.UTF_8));
|
List<String> ignoredModels = adapter.fromJson(new String(fileContent, StandardCharsets.UTF_8));
|
||||||
boolean confirmed = true;
|
boolean confirmed = true;
|
||||||
if (!Config.getInstance().getSettings().modelsIgnored.isEmpty()) {
|
if (!Config.getInstance().getSettings().ignoredModels.isEmpty()) {
|
||||||
String msg = "This will replace the existing ignore list! Continue?";
|
String msg = "This will replace the existing ignore list! Continue?";
|
||||||
AutosizeAlert confirm = new AutosizeAlert(AlertType.CONFIRMATION, msg, getScene(), YES, NO);
|
AutosizeAlert confirm = new AutosizeAlert(AlertType.CONFIRMATION, msg, getScene(), YES, NO);
|
||||||
confirm.setTitle("Import ignore list");
|
confirm.setTitle("Import ignore list");
|
||||||
|
@ -149,7 +149,7 @@ public class IgnoreList extends GridPane {
|
||||||
confirmed = confirm.getResult() == ButtonType.YES;
|
confirmed = confirm.getResult() == ButtonType.YES;
|
||||||
}
|
}
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
Config.getInstance().getSettings().modelsIgnored = ignoredModels;
|
Config.getInstance().getSettings().ignoredModels = ignoredModels;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -358,9 +358,9 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Model> filterIgnoredModels(List<Model> models) {
|
private List<Model> filterIgnoredModels(List<Model> models) {
|
||||||
List<Model> ignored = Config.getInstance().getSettings().modelsIgnored;
|
List<String> ignored = Config.getInstance().getSettings().ignoredModels;
|
||||||
return models.stream()
|
return models.stream()
|
||||||
.filter(m -> !ignored.contains(m))
|
.filter(m -> !ignored.contains(m.getUrl()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -181,6 +182,11 @@ public class Config {
|
||||||
settings.modelsIgnored.stream()
|
settings.modelsIgnored.stream()
|
||||||
.filter(m -> m instanceof Cam4Model)
|
.filter(m -> m instanceof Cam4Model)
|
||||||
.forEach(m -> m.setName(m.getName().toLowerCase()));
|
.forEach(m -> m.setName(m.getName().toLowerCase()));
|
||||||
|
// 4.1.2 reduce models ignore to store only the URL
|
||||||
|
settings.ignoredModels = settings.modelsIgnored.stream()
|
||||||
|
.map(Model::getUrl)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
settings.modelsIgnored = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeBackup(File source) {
|
private void makeBackup(File source) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class Settings {
|
||||||
public String httpUserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0";
|
public String httpUserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0";
|
||||||
public String httpUserAgentMobile = "Mozilla/5.0 (Android 9.0; Mobile; rv:82.0) Gecko/82.0 Firefox/82.0";
|
public String httpUserAgentMobile = "Mozilla/5.0 (Android 9.0; Mobile; rv:82.0) Gecko/82.0 Firefox/82.0";
|
||||||
public byte[] key = null;
|
public byte[] key = null;
|
||||||
|
public List<String> ignoredModels = new ArrayList<>();
|
||||||
public String lastDownloadDir = "";
|
public String lastDownloadDir = "";
|
||||||
public String livejasminBaseUrl = "https://www.livejasmin.com";
|
public String livejasminBaseUrl = "https://www.livejasmin.com";
|
||||||
public boolean livejasminBetaAcknowledged = false;
|
public boolean livejasminBetaAcknowledged = false;
|
||||||
|
@ -106,6 +107,7 @@ public class Settings {
|
||||||
public long minimumSpaceLeftInBytes = 0;
|
public long minimumSpaceLeftInBytes = 0;
|
||||||
public Map<String, String> modelNotes = new HashMap<>();
|
public Map<String, String> modelNotes = new HashMap<>();
|
||||||
public List<Model> models = new ArrayList<>();
|
public List<Model> models = new ArrayList<>();
|
||||||
|
@Deprecated
|
||||||
public List<Model> modelsIgnored = new ArrayList<>();
|
public List<Model> modelsIgnored = new ArrayList<>();
|
||||||
public boolean monitorClipboard = false;
|
public boolean monitorClipboard = false;
|
||||||
public int onlineCheckIntervalInSecs = 60;
|
public int onlineCheckIntervalInSecs = 60;
|
||||||
|
|
Loading…
Reference in New Issue