diff --git a/backend/src/api/endpoints/api_playlist_utils.rs b/backend/src/api/endpoints/api_playlist_utils.rs index 926046a69..7658e5433 100644 --- a/backend/src/api/endpoints/api_playlist_utils.rs +++ b/backend/src/api/endpoints/api_playlist_utils.rs @@ -146,7 +146,7 @@ pub(in crate::api::endpoints) async fn get_playlist(client: Arc Some(input) => { let (result, errors) = match input.input_type { - InputType::M3u | InputType::M3uBatch => m3u::get_m3u_playlist(client, cfg, input, &cfg.working_dir).await, + InputType::M3u | InputType::M3uBatch => m3u::get_m3u_playlist(&client, cfg, input, &cfg.working_dir).await, InputType::Xtream | InputType::XtreamBatch => xtream::get_xtream_playlist(cfg, &client, input, &cfg.working_dir).await, }; if result.is_empty() { diff --git a/backend/src/model/config/input.rs b/backend/src/model/config/input.rs index ff6b8607f..4524b66c9 100644 --- a/backend/src/model/config/input.rs +++ b/backend/src/model/config/input.rs @@ -92,7 +92,7 @@ impl From<&StagedInputDto> for StagedInput { } } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct ConfigInputAlias { pub id: u16, pub name: String, diff --git a/backend/src/processing/processor/playlist.rs b/backend/src/processing/processor/playlist.rs index 73ce77cf7..ea130548a 100644 --- a/backend/src/processing/processor/playlist.rs +++ b/backend/src/processing/processor/playlist.rs @@ -283,7 +283,7 @@ fn is_target_enabled(target: &ConfigTarget, user_targets: &ProcessTargets) -> bo async fn playlist_download_from_input(client: &Arc, config: &Arc, input: &Arc) -> (Vec, Vec) { let working_dir = &config.working_dir; match input.input_type { - InputType::M3u => m3u::get_m3u_playlist(Arc::clone(client), config, input, working_dir).await, + InputType::M3u => m3u::get_m3u_playlist(client, config, input, working_dir).await, InputType::Xtream => xtream::get_xtream_playlist(config, client, input, working_dir).await, InputType::M3uBatch | InputType::XtreamBatch => (vec![], vec![]) } diff --git a/backend/src/utils/network/m3u.rs b/backend/src/utils/network/m3u.rs index 91ae2544c..a29e0351a 100644 --- a/backend/src/utils/network/m3u.rs +++ b/backend/src/utils/network/m3u.rs @@ -6,10 +6,10 @@ use crate::processing::parser::m3u; use crate::utils::prepare_file_path; use crate::utils::request; -pub async fn get_m3u_playlist(client: Arc, cfg: &Config, input: &ConfigInput, working_dir: &str) -> (Vec, Vec) { +pub async fn get_m3u_playlist(client: &Arc, cfg: &Arc, input: &Arc, working_dir: &str) -> (Vec, Vec) { let input_source: InputSource = { match input.staged.as_ref() { - None => input.into(), + None => input.as_ref().into(), Some(staged) => staged.into(), } }; diff --git a/backend/src/utils/network/request.rs b/backend/src/utils/network/request.rs index 23445230e..8c907fd28 100644 --- a/backend/src/utils/network/request.rs +++ b/backend/src/utils/network/request.rs @@ -96,11 +96,11 @@ pub async fn get_input_epg_content_as_file(client: Arc, input: } -pub async fn get_input_text_content(client: Arc, input: &InputSource, working_dir: &str, persist_filepath: Option) -> Result { +pub async fn get_input_text_content(client: &Arc, input: &InputSource, working_dir: &str, persist_filepath: Option) -> Result { debug_if_enabled!("getting input text content working_dir: {}, url: {}", working_dir, sanitize_sensitive_info(&input.url)); if input.url.parse::().is_ok() { - match download_text_content(client, None, input, None, persist_filepath).await { + match download_text_content(Arc::clone(client), None, input, None, persist_filepath).await { Ok((content, _response_url)) => Ok(content), Err(e) => { error!("Failed to download input '{}': {}", &input.name, sanitize_sensitive_info(e.to_string().as_str())); diff --git a/backend/src/utils/network/xtream.rs b/backend/src/utils/network/xtream.rs index 12869164f..d37d06e97 100644 --- a/backend/src/utils/network/xtream.rs +++ b/backend/src/utils/network/xtream.rs @@ -6,7 +6,6 @@ use crate::processing::parser::xtream; use crate::repository::xtream_repository; use crate::repository::xtream_repository::{rewrite_xtream_series_info_content, rewrite_xtream_vod_info_content, xtream_get_input_info}; use crate::utils::request; -use chrono::DateTime; use log::{error, info, warn}; use shared::error::{str_to_io_error, TuliproxError}; use shared::model::{MsgKind, PlaylistEntry, PlaylistGroup, ProxyUserStatus, XtreamCluster, XtreamPlaylistItem}; @@ -172,10 +171,11 @@ async fn xtream_login(cfg: &Config, client: &Arc, input: &Input if expiration_ts > now_secs { let time_left = expiration_ts - now_secs; if time_left < 3 * 24 * 60 * 60 { - let datetime = DateTime::from_timestamp(expiration_timestamp, 0).unwrap(); - let formatted = datetime.format("%Y-%m-%d %H:%M:%S").to_string(); - warn!("User account for user {username} expires {formatted}"); - send_message(client, MsgKind::Info, cfg.messaging.as_ref(), &format!("User account for user {username} expires {formatted}")).await; + if let Some(datetime) = chrono::DateTime::from_timestamp(expiration_timestamp, 0) { + let formatted = datetime.format("%Y-%m-%d %H:%M:%S").to_string(); + warn!("User account for user {username} expires {formatted}"); + send_message(client, MsgKind::Info, cfg.messaging.as_ref(), &format!("User account for user {username} expires {formatted}")).await; + } } } else { warn!("User account for user {username} is expired"); @@ -204,8 +204,8 @@ pub async fn get_xtream_playlist(cfg: &Arc, client: &Arc, client: &Arc { match xtream::parse_xtream(input, @@ -260,16 +260,16 @@ fn check_alias_user_state(cfg: &Arc, client: &Arc, inpu if let Some(aliases) = input.aliases.as_ref() { for alias in aliases { // Random wait time 5–20 seconds to avoid provider block - let delay = fastrand::i32(5..=20) as u64; + let delay = u64::from(fastrand::u32(5..=20)); tokio::time::sleep(tokio::time::Duration::from_secs(delay)).await; if let (Some(username), Some(password)) = (alias.username.as_ref(), alias.password.as_ref()) { let mut input_source: InputSource = input.as_ref().into(); - input_source.username = alias.username.clone(); - input_source.password = alias.password.clone(); - input_source.url = alias.url.clone(); + input_source.username.clone_from(&alias.username); + input_source.password.clone_from(&alias.password); + input_source.url.clone_from(&alias.url); let base_url = get_xtream_stream_url_base( &input_source.url, username,