Early working version

This commit is contained in:
2023-03-05 19:14:26 +01:00
parent c97761bc00
commit 8290b67f25
7 changed files with 161 additions and 111 deletions

View File

@ -1,22 +1,23 @@
mod config;
mod downloader;
pub mod getm3u8;
mod grandmother;
mod m3u8;
mod opt;
mod parser;
mod playlist;
mod getm3u8;
use std::io::{stdin, stdout, Stdin, StdoutLock, Write};
use async_recursion::async_recursion;
pub use config::Configuration;
pub use downloader::download_with_progress;
pub use getm3u8::{GetM3u8, GetPlayPath, WatchedFind};
pub use grandmother::GrandMother;
pub use m3u8::{OfflineEntry, M3u8};
pub use m3u8::{M3u8, OfflineEntry};
pub use opt::{Mode, Opt};
pub use parser::Parser;
pub use parser::{OfflineParser, Parser};
pub use playlist::Playlist;
pub use getm3u8::GetM3u8;
pub const JSON_CONFIG_FILENAME: &'static str = "config.json";
pub const APP_IDENTIFIER: [&'static str; 3] = ["com", "billenius", "ilovetv"];
@ -56,3 +57,31 @@ pub unsafe fn get_mut_ref<T>(reference: &T) -> &mut T {
let ptr = reference as *const T as *mut T;
&mut *ptr
}
#[async_recursion(?Send)]
pub async fn get_gm(
mode: Mode,
readline: &mut Readline<'_>,
config: Configuration,
) -> Result<GrandMother, String> {
match mode {
Mode::Online => GrandMother::new(config).await,
Mode::Offline => Ok(GrandMother::new_offline(config)),
Mode::Ask => loop {
let input = readline
.input("Online/Offline mode? [1/2] ")
.trim()
.parse::<u8>();
if let Ok(num) = input {
if num == 1 {
return get_gm(Mode::Online, readline, config).await;
} else if num == 2 {
return get_gm(Mode::Offline, readline, config).await;
}
println!("Has to be either 1 (Onine) or 2 (Offline)");
} else {
println!("Has to be a number");
}
},
}
}