add a third variant for cs keys...

This commit is contained in:
Sebastian Hugentobler 2017-03-23 15:18:18 +01:00
parent a5609bc344
commit e11a699de7
3 changed files with 13 additions and 6 deletions

2
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Debug",
"type": "lldb-mi",
"request": "launch",
"target": "./target/debug/gog-backup",
"target": "./target/debug/gog-sync",
"cwd": "${workspaceRoot}"
}
]

View File

@ -134,7 +134,7 @@ impl<'a> Gog<'a> {
let mut config: Config = match configfiles.load("config.json") {
Ok(value) => value,
Err(_) => {
error!("Configuration error, generating new one...");
error!("Configuration error, generating new one");
Config {
game_storage: String::from(storage_path),
@ -340,9 +340,16 @@ impl<'a> Gog<'a> {
fn parse_cd_keys(&self, content_title: &str, raw_cd_keys: &str) -> BTreeMap<String, String> {
let mut cd_keys = BTreeMap::new();
let mut raw_cd_keys_fix = raw_cd_keys.to_owned();
if raw_cd_keys.contains("<br>") {
let splitted_keys = raw_cd_keys.split("<br>");
if raw_cd_keys_fix.contains("<span>") {
raw_cd_keys_fix = raw_cd_keys_fix.replace("</span><span>", "<br>")
.replace("<span>", "")
.replace("</span>", "");
}
if raw_cd_keys_fix.contains("<br>") {
let splitted_keys = raw_cd_keys_fix.split("<br>");
let mut key_names: Vec<String> = Vec::new();
let mut key_values: Vec<String> = Vec::new();
@ -361,8 +368,8 @@ impl<'a> Gog<'a> {
let key_value = key_values[index].clone();
cd_keys.insert(key_name.clone(), key_value);
}
} else if !raw_cd_keys.is_empty() {
cd_keys.insert(content_title.to_owned(), raw_cd_keys.trim().to_owned());
} else if !raw_cd_keys_fix.is_empty() {
cd_keys.insert(content_title.to_owned(), raw_cd_keys_fix.trim().to_owned());
}
return cd_keys;