print error and also better welcome message
This commit is contained in:
parent
984c426df2
commit
60fc85772a
@ -71,11 +71,10 @@ pub async fn download_with_progress(
|
|||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.or(Err("Failed to connect server".to_owned()))?;
|
.or(Err("Failed to connect server".to_owned()))?;
|
||||||
let content_length = match resp.content_length() {
|
let content_length = if let Some(s) = resp.content_length() {
|
||||||
Some(k) => k,
|
s
|
||||||
None => {
|
} else {
|
||||||
panic!("Could not retrive content length from server. {:?}", &resp);
|
panic!("Could not retrive content length from server. {:?}", &resp);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let pb = ProgressBar::new(content_length);
|
let pb = ProgressBar::new(content_length);
|
||||||
|
@ -60,6 +60,6 @@ impl<'a> Readline<'a> {
|
|||||||
self.stdout.flush().unwrap();
|
self.stdout.flush().unwrap();
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
self.stdin.read_line(&mut buffer).unwrap();
|
self.stdin.read_line(&mut buffer).unwrap();
|
||||||
buffer.to_lowercase()
|
buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
src/main.rs
21
src/main.rs
@ -7,9 +7,13 @@ use iptvnator::{download_with_progress, setup, M3u8, Parser, Readline};
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
println!("Welcome to iptvnator, the port and extension of my previous program pyiptvnator, now in rust BLAZINGLY FAST\n");
|
|
||||||
println!(
|
println!(
|
||||||
"There will be some options along the way \n {} is for refreshing your iptvfile.\n {} is to quit and save watched feeds\n {} is to download fields\n {} is to perform a new search\n {} means all",
|
"Welcome to {}, a {} iptv client written in rust\n",
|
||||||
|
"iptvnator".bold(),
|
||||||
|
"BLAZINGLY FAST".italic()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"There will be some options along the way \n {} is to refresh the local iptvfile.\n {} is to quit and save watched fields\n {} is to download fields\n {} is to perform a new search\n {} is to select all",
|
||||||
"r".bold(),"q".bold(),"d".bold(),"s".bold(),"a".bold()
|
"r".bold(),"q".bold(),"d".bold(),"s".bold(),"a".bold()
|
||||||
);
|
);
|
||||||
let parser = Parser::new("iptv.m3u8".to_owned(), setup(), "watched.txt".to_owned()).await;
|
let parser = Parser::new("iptv.m3u8".to_owned(), setup(), "watched.txt".to_owned()).await;
|
||||||
@ -20,7 +24,7 @@ async fn main() {
|
|||||||
loop {
|
loop {
|
||||||
// Dont't perform a search if user has just watched, instead present the previous search
|
// Dont't perform a search if user has just watched, instead present the previous search
|
||||||
if search_result.is_none() {
|
if search_result.is_none() {
|
||||||
let search = readline.input("Search by name [r | q]: ");
|
let search = readline.input("Search by name [r | q]: ").to_lowercase();
|
||||||
let search = search.trim();
|
let search = search.trim();
|
||||||
|
|
||||||
// If they want to quit, let them-
|
// If they want to quit, let them-
|
||||||
@ -45,7 +49,9 @@ async fn main() {
|
|||||||
println!(" {}: {}", idx + 1, m3u8_item);
|
println!(" {}: {}", idx + 1, m3u8_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_wish = readline.input("Which one do you wish to stream? [ q/s/r/d ]: ");
|
let user_wish = readline
|
||||||
|
.input("Which one do you wish to stream? [ q/s/r/d ]: ")
|
||||||
|
.to_lowercase();
|
||||||
let user_wish = user_wish.trim();
|
let user_wish = user_wish.trim();
|
||||||
|
|
||||||
// If they want to quit, let them-
|
// If they want to quit, let them-
|
||||||
@ -60,8 +66,9 @@ async fn main() {
|
|||||||
refresh(&parser).await;
|
refresh(&parser).await;
|
||||||
continue;
|
continue;
|
||||||
} else if user_wish == "d" {
|
} else if user_wish == "d" {
|
||||||
let selection =
|
let selection = readline
|
||||||
readline.input("Download all or select in comma separated [a | 1,2,3,4]: ");
|
.input("Download all or select in comma separated [a | 1,2,3,4]: ")
|
||||||
|
.to_lowercase();
|
||||||
let selection = selection.trim();
|
let selection = selection.trim();
|
||||||
|
|
||||||
let to_download = loop {
|
let to_download = loop {
|
||||||
@ -76,7 +83,7 @@ async fn main() {
|
|||||||
|
|
||||||
for selection in selections.iter() {
|
for selection in selections.iter() {
|
||||||
if selection.is_err() {
|
if selection.is_err() {
|
||||||
println!("Not a valid number");
|
println!("Not a valid number or the option {}", "a".bold());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user