forked from j62/ctbrec
Add migration step for Cam4 model notes
This commit is contained in:
parent
ec71dc3c6d
commit
e3925e992d
|
@ -1,10 +1,10 @@
|
|||
package ctbrec;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.*;
|
||||
import static java.nio.file.StandardOpenOption.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -13,7 +13,9 @@ import java.time.LocalDateTime;
|
|||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -33,6 +35,7 @@ import ctbrec.recorder.postprocessing.PostProcessor;
|
|||
import ctbrec.recorder.postprocessing.RemoveKeepFile;
|
||||
import ctbrec.recorder.postprocessing.Script;
|
||||
import ctbrec.sites.Site;
|
||||
import ctbrec.sites.cam4.Cam4Model;
|
||||
|
||||
public class Config {
|
||||
|
||||
|
@ -79,7 +82,7 @@ public class Config {
|
|||
fileContent[1] = ' ';
|
||||
fileContent[2] = ' ';
|
||||
}
|
||||
String json = new String(fileContent, StandardCharsets.UTF_8.name()).trim();
|
||||
String json = new String(fileContent, UTF_8).trim();
|
||||
settings = adapter.fromJson(json);
|
||||
settings.httpTimeout = Math.max(settings.httpTimeout, 10_000);
|
||||
if (settings.recordingsDir.endsWith("/")) {
|
||||
|
@ -161,6 +164,16 @@ public class Config {
|
|||
LOG.error("Couldn't migrate minimal browser config location", e);
|
||||
}
|
||||
}
|
||||
// 3.10.10 model notes due to Cam4 URL change
|
||||
for (Iterator<Entry<String, String>> iterator = settings.modelNotes.entrySet().iterator(); iterator.hasNext();) {
|
||||
Entry<String, String> note = iterator.next();
|
||||
if (note.getKey().contains("cam4") && note.getKey().endsWith("/")) {
|
||||
Cam4Model model = new Cam4Model();
|
||||
model.setUrl(note.getKey());
|
||||
settings.modelNotes.put(model.getUrl(), note.getValue());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeBackup(File source) {
|
||||
|
@ -204,7 +217,7 @@ public class Config {
|
|||
File configFile = new File(configDir, filename);
|
||||
LOG.debug("Saving config to {}", configFile.getAbsolutePath());
|
||||
Files.createDirectories(configDir.toPath());
|
||||
Files.write(configFile.toPath(), json.getBytes("utf-8"), CREATE, WRITE, TRUNCATE_EXISTING);
|
||||
Files.write(configFile.toPath(), json.getBytes(UTF_8), CREATE, WRITE, TRUNCATE_EXISTING);
|
||||
}
|
||||
|
||||
public static boolean isServerMode() {
|
||||
|
|
Loading…
Reference in New Issue