diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc5a0d4f..351b85b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ epg: `-m /home/tuliprox/config/mapping.d` The files are loaded in **alphanumeric** order. **Note:** This is a lexicographic sort — so `m_10.yml` comes before `m_2.yml` unless you name files carefully (e.g., `m_01.yml`, `m_02.yml`, ..., `m_10.yml`). +- Added `mapping_path` to `config.yml`. # 3.0.0 (2025-05-12) - !BREAKING_CHANGE! user has now the attribute `ui_enabled` to disable/enable web_ui for user. diff --git a/src/api/config_watch.rs b/src/api/config_watch.rs index 044e78038..fe3dc34f1 100644 --- a/src/api/config_watch.rs +++ b/src/api/config_watch.rs @@ -95,7 +95,7 @@ pub async fn exec_config_watch(app_state: &Arc) -> Result<(), Tuliprox error!("Failed to reload config file {path:?}: {err}"); } } else if recursive_mode == RecursiveMode::Recursive && path.extension().is_some_and(|ext| ext == "yml") { - for (key, (config_file, is_dir)) in files.iter() { + for (key, (config_file, is_dir)) in &files { if *is_dir && path.starts_with(key) { if let Err(err) = config_file.reload(&path, &watcher_app_state) { error!("Failed to reload config file {path:?}: {err}"); diff --git a/src/model/config.rs b/src/model/config.rs index cc750cc56..404b525f9 100644 --- a/src/model/config.rs +++ b/src/model/config.rs @@ -345,6 +345,8 @@ pub struct Config { #[serde(default, skip_serializing_if = "Option::is_none")] pub user_config_dir: Option, #[serde(default, skip_serializing_if = "Option::is_none")] + pub mapping_path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] pub custom_stream_response: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub templates: Option>, @@ -645,6 +647,9 @@ impl Config { pub fn prepare(&mut self, include_computed: bool) -> Result<(), TuliproxError> { let work_dir = &self.working_dir; self.working_dir = utils::resolve_directory_path(work_dir); + if let Some(mapping_path) = &self.mapping_path { + self.t_mapping_file_path = mapping_path.to_string(); + } if include_computed { self.t_access_token_secret = generate_secret(); self.t_encrypt_secret = <&[u8] as TryInto<[u8; 16]>>::try_into(&generate_secret()[0..16]).map_err(|err| TuliproxError::new(TuliproxErrorKind::Info, err.to_string()))?; diff --git a/src/processing/processor/playlist.rs b/src/processing/processor/playlist.rs index ea6473e0e..307fdc307 100644 --- a/src/processing/processor/playlist.rs +++ b/src/processing/processor/playlist.rs @@ -161,7 +161,7 @@ fn map_playlist(playlist: &mut [PlaylistGroup], target: &ConfigTarget) -> Option if let Some(mappings) = target.t_mapping.load().as_ref() { let new_playlist: Vec = playlist.iter().map(|playlist_group| { let mut grp = playlist_group.clone(); - mappings.iter().filter(|&mapping| mapping.mapper.as_ref().map_or(false, |v| !v.is_empty())) + mappings.iter().filter(|&mapping| mapping.mapper.as_ref().is_some_and(|v| !v.is_empty())) .for_each(|mapping| grp.channels = grp.channels.drain(..).map(|chan| map_channel(chan, mapping)).collect()); grp