mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-30 18:52:31 +01:00
24 lines
938 B
Rust
24 lines
938 B
Rust
use std::sync::Arc;
|
|
use shared::error::TuliproxError;
|
|
use shared::model::PlaylistGroup;
|
|
use crate::model::{Config, ConfigInput, InputSource};
|
|
use crate::processing::parser::m3u;
|
|
use crate::utils::prepare_file_path;
|
|
use crate::utils::request;
|
|
|
|
pub async fn get_m3u_playlist(client: &reqwest::Client, cfg: &Arc<Config>, input: &Arc<ConfigInput>, working_dir: &str) -> (Vec<PlaylistGroup>, Vec<TuliproxError>) {
|
|
let input_source: InputSource = {
|
|
match input.staged.as_ref() {
|
|
None => input.as_ref().into(),
|
|
Some(staged) => staged.into(),
|
|
}
|
|
};
|
|
let persist_file_path = prepare_file_path(input.persist.as_deref(), working_dir, "");
|
|
match request::get_input_text_content_as_stream(client, &input_source, working_dir, persist_file_path).await {
|
|
Ok(reader) => {
|
|
(m3u::parse_m3u(cfg, input, reader).await, vec![])
|
|
}
|
|
Err(err) => (vec![], vec![err])
|
|
}
|
|
}
|