[feat] read video config is ok
This commit is contained in:
@@ -48,55 +48,55 @@ pub fn to_vdf(json_data: &str) -> String {
|
||||
}
|
||||
|
||||
fn build_vdf(json_value: &serde_json::Value, vdf_data: &mut String, indent_level: usize) {
|
||||
match json_value {
|
||||
serde_json::Value::Object(obj) => {
|
||||
for (key, value) in obj {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\n", key));
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str("{\n");
|
||||
build_vdf(value, vdf_data, indent_level + 1);
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str("}\n");
|
||||
}
|
||||
}
|
||||
serde_json::Value::String(s) => {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\t\t\"{}\"\n", s, s));
|
||||
}
|
||||
_ => {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\t\t\"{}\"\n", json_value, json_value));
|
||||
}
|
||||
}
|
||||
match json_value {
|
||||
serde_json::Value::Object(obj) => {
|
||||
for (key, value) in obj {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\n", key));
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str("{\n");
|
||||
build_vdf(value, vdf_data, indent_level + 1);
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str("}\n");
|
||||
}
|
||||
}
|
||||
serde_json::Value::String(s) => {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\t\t\"{}\"\n", s, s));
|
||||
}
|
||||
_ => {
|
||||
vdf_data.push_str(&"\t".repeat(indent_level));
|
||||
vdf_data.push_str(&format!("\"{}\"\t\t\"{}\"\n", json_value, json_value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
static VDF_DATA: &str = r#"\"users\"
|
||||
static VDF_DATA: &str = r#""users"
|
||||
{
|
||||
\"76561198315078806\"
|
||||
"76561198315078806"
|
||||
{
|
||||
\"AccountName\" \"_jerry_dota2\"
|
||||
\"PersonaName\" \"Rop紫(已黑化)\"
|
||||
\"RememberPassword\" \"1\"
|
||||
\"WantsOfflineMode\" \"0\"
|
||||
\"SkipOfflineModeWarning\" \"0\"
|
||||
\"AllowAutoLogin\" \"1\"
|
||||
\"MostRecent\" \"1\"
|
||||
\"Timestamp\" \"1742706884\"
|
||||
"AccountName" "_jerry_dota2"
|
||||
"PersonaName" "Rop紫(已黑化)"
|
||||
"RememberPassword" "1"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AllowAutoLogin" "1"
|
||||
"MostRecent" "1"
|
||||
"Timestamp" "1742706884"
|
||||
}
|
||||
\"76561198107125441\"
|
||||
"76561198107125441"
|
||||
{
|
||||
\"AccountName\" \"_im_ai_\"
|
||||
\"PersonaName\" \"Buongiorno\"
|
||||
\"RememberPassword\" \"1\"
|
||||
\"WantsOfflineMode\" \"0\"
|
||||
\"SkipOfflineModeWarning\" \"0\"
|
||||
\"AllowAutoLogin\" \"1\"
|
||||
\"MostRecent\" \"0\"
|
||||
\"Timestamp\" \"1739093763\"
|
||||
"AccountName" "_im_ai_"
|
||||
"PersonaName" "Buongiorno"
|
||||
"RememberPassword" "1"
|
||||
"WantsOfflineMode" "0"
|
||||
"SkipOfflineModeWarning" "0"
|
||||
"AllowAutoLogin" "1"
|
||||
"MostRecent" "0"
|
||||
"Timestamp" "1739093763"
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
Reference in New Issue
Block a user