better code aestitichally

This commit is contained in:
Love 2023-01-17 20:59:19 +01:00
parent 118d25796d
commit d9547c1cb8

View File

@ -20,26 +20,32 @@ pub fn setup() -> String {
return fs::read_to_string(&ilovetv_config_file).expect("Failed to read iptv_url");
}
println!("Hello, I would need an url to your iptv/m3u/m3u8 stream");
print!("enter url: ");
let mut stdout = stdout().lock();
stdout.flush().unwrap();
let mut url = String::new();
let stdin = stdin();
let _ = stdin.read_line(&mut url);
print!("Are you sure? (Y/n) ");
stdout.flush().unwrap();
let mut yn = String::new();
let _ = stdin.read_line(&mut yn);
if yn.trim() == "n" {
setup();
}
println!("Hello, I would need an url to your iptv/m3u/m3u8 stream");
let url = loop {
print!("enter url: ");
stdout.flush().unwrap();
let mut url = String::new();
let _ = stdin.read_line(&mut url);
print!("Are you sure? (Y/n) ");
stdout.flush().unwrap();
let mut yn = String::new();
yn = String::new();
let _ = stdin.read_line(&mut yn);
if yn.to_lowercase() != "n" {
break url.trim().to_string();
}
};
let _ = fs::create_dir_all(config_dir);
if let Err(e) = fs::write(ilovetv_config_file, url.trim()) {
if let Err(e) = fs::write(ilovetv_config_file, &url) {
eprintln!("{:?}", e);
process::exit(-1);
}
url.to_string()
url
}