Default sort removed,

updated steps only log if enabled
This commit is contained in:
euzu
2025-09-23 16:56:56 +02:00
parent 41a3bb8ffc
commit 3a872c81ca
5 changed files with 36 additions and 19 deletions
+19 -10
View File
@@ -507,43 +507,49 @@ async fn process_playlist_for_target(app_config: &AppConfig,
info!("Playlist is empty: {}", &target.name);
Ok(())
} else {
// Process Trakt categories
trakt_playlist(&client, target, errors, &mut new_playlist).await;
step.tick("trakt categories");
if trakt_playlist(&client, target, errors, &mut new_playlist).await {
step.tick("trakt categories");
}
let mut flat_new_playlist = flatten_groups(new_playlist);
step.tick("playlist merge");
sort_playlist(target, &mut flat_new_playlist);
step.tick("playlist sort");
if sort_playlist(target, &mut flat_new_playlist) {
step.tick("playlist sort");
}
assign_channel_no_playlist(&mut flat_new_playlist);
step.tick("assigning channel numbers");
map_playlist_counter(target, &mut flat_new_playlist);
step.tick("assigning channel counter");
let config = app_config.config.load();
process_watch(&config, &client, target, &flat_new_playlist);
step.tick("group watches");
if process_watch(&config, &client, target, &flat_new_playlist) {
step.tick("group watches");
}
let result = persist_playlist(app_config, &mut flat_new_playlist, flatten_tvguide(&new_epg).as_ref(), target).await;
step.stop("Persisting playlists");
result
}
}
async fn trakt_playlist(client: &Arc<Client>, target: &ConfigTarget, errors: &mut Vec<TuliproxError>, playlist: &mut Vec<PlaylistGroup>) {
async fn trakt_playlist(client: &Arc<Client>, target: &ConfigTarget, errors: &mut Vec<TuliproxError>, playlist: &mut Vec<PlaylistGroup>) -> bool {
match process_trakt_categories_for_target(Arc::clone(client), playlist, target).await {
Ok(trakt_categories) => {
Ok(Some(trakt_categories)) => {
if !trakt_categories.is_empty() {
info!("Adding {} Trakt categories to playlist", trakt_categories.len());
playlist.extend(trakt_categories);
}
}
Ok(None) => {
return false;
}
Err(trakt_errors) => {
warn!("Trakt processing failed with {} errors", trakt_errors.len());
errors.extend(trakt_errors);
}
}
true
}
fn process_epg(processed_fetched_playlists: &mut Vec<FetchedPlaylist>) -> (Vec<Epg>, Vec<PlaylistGroup>) {
@@ -559,7 +565,7 @@ fn process_epg(processed_fetched_playlists: &mut Vec<FetchedPlaylist>) -> (Vec<E
(new_epg, new_playlist)
}
fn process_watch(cfg: &Config, client: &Arc<reqwest::Client>, target: &ConfigTarget, new_playlist: &Vec<PlaylistGroup>) {
fn process_watch(cfg: &Config, client: &Arc<reqwest::Client>, target: &ConfigTarget, new_playlist: &Vec<PlaylistGroup>) -> bool {
if let Some(watches) = &target.watch {
if default_as_default().eq_ignore_ascii_case(&target.name) {
error!("cant watch a target with no unique name");
@@ -570,6 +576,9 @@ fn process_watch(cfg: &Config, client: &Arc<reqwest::Client>, target: &ConfigTar
}
}
}
true
} else {
false
}
}
+4 -1
View File
@@ -115,7 +115,7 @@ fn playlistitem_comparator(
playlist_comparator(channel_sort.sequence.as_ref(), channel_sort.order, &value_a, &value_b)
}
pub(in crate::processing::processor) fn sort_playlist(target: &ConfigTarget, new_playlist: &mut [PlaylistGroup]) {
pub(in crate::processing::processor) fn sort_playlist(target: &ConfigTarget, new_playlist: &mut [PlaylistGroup]) -> bool {
if let Some(sort) = &target.sort {
let match_as_ascii = sort.match_as_ascii;
if let Some(group_sort) = &sort.groups {
@@ -132,6 +132,9 @@ pub(in crate::processing::processor) fn sort_playlist(target: &ConfigTarget, new
}
}
}
true
} else {
false
}
}
+5 -5
View File
@@ -253,10 +253,10 @@ impl TraktCategoriesProcessor {
playlist: &[PlaylistGroup],
target: &ConfigTarget,
trakt_config: &TraktConfig,
) -> Result<Vec<PlaylistGroup>, Vec<TuliproxError>> {
) -> Result<Option<Vec<PlaylistGroup>>, Vec<TuliproxError>> {
if trakt_config.lists.is_empty() {
debug!("No Trakt lists configured for target {}", target.name);
return Ok(vec![]);
return Ok(None);
}
info!("Processing {} Trakt lists for target {}", trakt_config.lists.len(), target.name);
@@ -288,17 +288,17 @@ impl TraktCategoriesProcessor {
info!("Trakt processing complete: created {} categories with {total_matches} total matches",
new_categories.len());
Ok(new_categories)
Ok(Some(new_categories))
}
}
pub async fn process_trakt_categories_for_target(
http_client: Arc<reqwest::Client>,
playlist: &[PlaylistGroup],
target: &ConfigTarget,
) -> Result<Vec<PlaylistGroup>, Vec<TuliproxError>> {
) -> Result<Option<Vec<PlaylistGroup>>, Vec<TuliproxError>> {
let Some(trakt_config) = target.get_xtream_output().and_then(|output| output.trakt.as_ref()) else {
debug!("No Trakt configuration found for target {}", target.name);
return Ok(vec![]);
return Ok(None);
};
let processor = TraktCategoriesProcessor::new(http_client, trakt_config);