better code aestitichally
This commit is contained in:
parent
118d25796d
commit
d9547c1cb8
34
src/lib.rs
34
src/lib.rs
@ -20,26 +20,32 @@ pub fn setup() -> String {
|
|||||||
return fs::read_to_string(&ilovetv_config_file).expect("Failed to read iptv_url");
|
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();
|
let mut stdout = stdout().lock();
|
||||||
stdout.flush().unwrap();
|
|
||||||
let mut url = String::new();
|
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
let _ = stdin.read_line(&mut url);
|
|
||||||
print!("Are you sure? (Y/n) ");
|
println!("Hello, I would need an url to your iptv/m3u/m3u8 stream");
|
||||||
stdout.flush().unwrap();
|
let url = loop {
|
||||||
let mut yn = String::new();
|
print!("enter url: ");
|
||||||
let _ = stdin.read_line(&mut yn);
|
stdout.flush().unwrap();
|
||||||
if yn.trim() == "n" {
|
let mut url = String::new();
|
||||||
setup();
|
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);
|
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);
|
eprintln!("{:?}", e);
|
||||||
process::exit(-1);
|
process::exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
url.to_string()
|
url
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user