added sah url handling,

some refactorings,
added provider connection check,
This commit is contained in:
euzu
2025-03-19 09:54:59 +01:00
parent 61b3eeb461
commit 5ffaf48267
29 changed files with 405 additions and 336 deletions
+5 -5
View File
@@ -4,14 +4,14 @@ use crate::model::hls::HlsEntry;
use std::collections::HashMap;
use std::str;
use tokio::time::Instant;
use crate::utils::hash_utils::uuid_v4;
use crate::utils::string_utils::replace_after_last_slash;
pub const HLS_PREFIX: &str = "hls";
pub fn rewrite_hls(base_url: &str, content: &str, hls_url: &str, virtual_id: u32, user: &ProxyUserCredentials,
target_type: &TargetType, input_name: &str) -> (HlsEntry, String) {
let token = uuid_v4();
pub fn rewrite_hls(base_url: &str, content: &str, hls_url: &str, virtual_id: u32,
token: u32,
user: &ProxyUserCredentials,
target_type: &TargetType, input_id: u16) -> (HlsEntry, String) {
let username = &user.username;
let password = &user.password;
let mut chunk: u32 = 1;
@@ -36,7 +36,7 @@ pub fn rewrite_hls(base_url: &str, content: &str, hls_url: &str, virtual_id: u32
ts: Instant::now(),
token,
target_type: target_type.clone(),
input_name: input_name.to_string(),
input_id,
virtual_id,
chunk,
chunks,
+4 -4
View File
@@ -49,7 +49,7 @@ pub(in crate::processing) fn write_info_content_to_wal_file(writer: &mut BufWrit
}
pub(in crate::processing) fn create_resolve_episode_wal_files(cfg: &Config, input: &ConfigInput) -> Option<(File, PathBuf)> {
match get_input_storage_path(input, &cfg.working_dir) {
match get_input_storage_path(&input.name, &cfg.working_dir) {
Ok(storage_path) => {
let info_path = storage_path.join(format!("{FILE_SERIES_EPISODE_RECORD}.{FILE_SUFFIX_WAL}"));
let info_file = append_or_crate_file(&info_path).ok()?;
@@ -60,7 +60,7 @@ pub(in crate::processing) fn create_resolve_episode_wal_files(cfg: &Config, inpu
}
pub(in crate::processing) fn create_resolve_info_wal_files(cfg: &Config, input: &ConfigInput, cluster: XtreamCluster) -> Option<(File, File, PathBuf, PathBuf)> {
match get_input_storage_path(input, &cfg.working_dir) {
match get_input_storage_path(&input.name, &cfg.working_dir) {
Ok(storage_path) => {
if let Some(file_prefix) = match cluster {
XtreamCluster::Live => None,
@@ -96,12 +96,12 @@ where
{
let mut processed_info_ids = HashMap::new();
let file_path = match get_input_storage_path(fpl.input, &cfg.working_dir)
let fpl_name = &fpl.input.name;
let file_path = match get_input_storage_path(fpl_name, &cfg.working_dir)
.map(|storage_path| xtream_get_record_file_path(&storage_path, item_type)).and_then(|opt| opt.ok_or_else(|| str_to_io_error("Not supported")))
{
Ok(file_path) => file_path,
Err(err) => {
let fpl_name = &fpl.input.name;
errors.push(notify_err!(format!("Could not create storage path for input {fpl_name}: {err}")));
return processed_info_ids;
}
+1 -1
View File
@@ -139,7 +139,7 @@ async fn process_series_info(
let mut result: Vec<PlaylistGroup> = vec![];
let input = fpl.input;
let Ok(Some((info_path, idx_path))) = get_input_storage_path(input, &cfg.working_dir)
let Ok(Some((info_path, idx_path))) = get_input_storage_path(&input.name, &cfg.working_dir)
.map(|storage_path| xtream_get_info_file_paths(&storage_path, XtreamCluster::Series))
else {
errors.push(notify_err!("Failed to open input info file for series".to_string()));