more options
This commit is contained in:
parent
608176262d
commit
f4c184b2c7
29
src/main.rs
29
src/main.rs
@ -2,11 +2,16 @@ use std::num::ParseIntError;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use colored::Colorize;
|
||||||
use iptvnator_rs::{download_with_progress, setup, M3u8, Parser, Readline};
|
use iptvnator_rs::{download_with_progress, setup, M3u8, Parser, Readline};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
println!("Welcome to iptvnator_rs, the port of my iptvprogram written in python, now in rust BLAZINGLY FAST\n");
|
println!("Welcome to iptvnator_rs, the port of my iptvprogram written in python, now in rust BLAZINGLY FAST\n");
|
||||||
|
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",
|
||||||
|
"r".bold(),"q".bold(),"d".bold(),"s".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;
|
||||||
|
|
||||||
let mut search_result: Option<Rc<Vec<&M3u8>>> = None;
|
let mut search_result: Option<Rc<Vec<&M3u8>>> = None;
|
||||||
@ -15,12 +20,16 @@ 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: ");
|
let search = readline.input("Search by name [r | q]: ");
|
||||||
let search = search.trim();
|
let search = search.trim();
|
||||||
|
|
||||||
// If they want to quit, let them-
|
// If they want to quit, let them-
|
||||||
if search == "q" {
|
if search == "q" {
|
||||||
break;
|
break;
|
||||||
|
} else if search == "r" {
|
||||||
|
search_result = None;
|
||||||
|
refresh(&parser).await;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
search_result = Some(Rc::new(parser.find(search)));
|
search_result = Some(Rc::new(parser.find(search)));
|
||||||
@ -48,14 +57,7 @@ async fn main() {
|
|||||||
} else if user_wish == "r" {
|
} else if user_wish == "r" {
|
||||||
println!("Refreshing local m3u8-file");
|
println!("Refreshing local m3u8-file");
|
||||||
search_result = None;
|
search_result = None;
|
||||||
|
refresh(&parser).await;
|
||||||
// I know that this is also frowned upon, but it is perfectly safe right here,
|
|
||||||
// even though the borrowchecker complains
|
|
||||||
{
|
|
||||||
let ptr = &parser as *const Parser as *mut Parser;
|
|
||||||
let p = unsafe { &mut *ptr };
|
|
||||||
p.forcefully_update().await;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
} else if user_wish == "d" {
|
} else if user_wish == "d" {
|
||||||
let selection = readline.input("Download all or select in comma separated [A]: ");
|
let selection = readline.input("Download all or select in comma separated [A]: ");
|
||||||
@ -102,6 +104,15 @@ async fn main() {
|
|||||||
parser.save_watched();
|
parser.save_watched();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I know that this is also frowned upon, but it is perfectly safe right here,
|
||||||
|
* even though the borrowchecker complains
|
||||||
|
*/
|
||||||
|
async fn refresh(parser: &Parser) {
|
||||||
|
let ptr = parser as *const Parser as *mut Parser;
|
||||||
|
let p = unsafe { &mut *ptr };
|
||||||
|
p.forcefully_update().await;
|
||||||
|
}
|
||||||
async fn download_m3u8(files_to_download: Rc<Vec<&M3u8>>) {
|
async fn download_m3u8(files_to_download: Rc<Vec<&M3u8>>) {
|
||||||
for m3u8 in files_to_download.iter() {
|
for m3u8 in files_to_download.iter() {
|
||||||
let file_ending_place = m3u8.link.rfind(".").unwrap();
|
let file_ending_place = m3u8.link.rfind(".").unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user