From 307ed6610ee23a908baee9f2c8df10e2fb4c58b1 Mon Sep 17 00:00:00 2001 From: euzu Date: Fri, 13 Oct 2023 15:56:00 +0200 Subject: [PATCH] fixed multiple targets had no content problem occured after refactoring --- README.md | 2 +- src/model/model_m3u.rs | 4 ++-- src/playlist_processor.rs | 21 ++++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b7ed9915d..c6221c21c 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ Has the following top level entries: #### 2.3.4.1 `filter` The filter is a string with a statement (@see filter statements). -It is optional and allows you to +It is optional and allows you to filter the content. #### 2.3.4.2 `pattern` The pattern is a string with a statement (@see filter statements). diff --git a/src/model/model_m3u.rs b/src/model/model_m3u.rs index 00fbc2c78..8d709f23f 100644 --- a/src/model/model_m3u.rs +++ b/src/model/model_m3u.rs @@ -7,8 +7,8 @@ use crate::model::config::{ConfigInput, ConfigOptions}; // https://siptv.eu/howto/playlist.html #[derive(Debug, Clone)] -pub(crate) struct FetchedPlaylist { - pub input: ConfigInput, +pub(crate) struct FetchedPlaylist<'a> { + pub input: &'a ConfigInput, pub playlist: Vec, } diff --git a/src/playlist_processor.rs b/src/playlist_processor.rs index 72d8cf6e8..2919c41c9 100644 --- a/src/playlist_processor.rs +++ b/src/playlist_processor.rs @@ -277,7 +277,7 @@ fn process_source(cfg: Arc, source_idx: usize, user_targets: Arc = vec![]; + playlists.iter_mut().for_each(|fpl| { + let mut new_fpl = FetchedPlaylist { + input: fpl.input, + playlist: fpl.playlist.clone(), + }; for f in &pipe { - let r = f(&mut pl.playlist, target); + let playlist = &mut new_fpl.playlist; + let r = f(playlist, target); if let Some(v) = r { - pl.playlist = v; + new_fpl.playlist = v; } } + new_fetched_playlist.push(new_fpl); }); - apply_affixes(playlists); - let mut new_playlist = Vec::new(); - playlists.iter_mut().for_each(|fp| { + apply_affixes(&mut new_fetched_playlist); + let mut new_playlist = vec![]; + new_fetched_playlist.iter_mut().for_each(|fp| { fp.playlist.drain(..).for_each(|group| new_playlist.push(group)); });