mirror of
https://github.com/euzu/tuliprox.git
synced 2026-09-30 13:02:10 +02:00
Add is_trakt_group field to PlaylistGroup and update sorting logic
- Introduced `is_trakt_group` field in `PlaylistGroup` struct to differentiate between Trakt and non-Trakt groups. - Updated relevant parsing functions in `m3u.rs`, `xtream.rs`, and `trakt.rs` to set this field appropriately. - Enhanced sorting logic in `sort.rs` to prioritize Trakt groups during playlist sorting. - Ensured backward compatibility by defaulting `is_trakt_group` to false where applicable.
This commit is contained in:
@@ -55,6 +55,7 @@ fn filter_playlist(playlist: &mut [PlaylistGroup], target: &ConfigTarget) -> Opt
|
||||
title: pg.title.clone(),
|
||||
channels,
|
||||
xtream_cluster: pg.xtream_cluster,
|
||||
is_trakt_group: pg.is_trakt_group,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -175,6 +176,7 @@ fn map_playlist(playlist: &mut [PlaylistGroup], target: &ConfigTarget) -> Option
|
||||
title: title.to_string(),
|
||||
channels: vec![channel.clone()],
|
||||
xtream_cluster: *cluster,
|
||||
is_trakt_group: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,20 @@ fn playlist_comparator(
|
||||
}
|
||||
}
|
||||
|
||||
fn trakt_priority_comparator(a: &PlaylistGroup, b: &PlaylistGroup) -> Option<Ordering> {
|
||||
match (a.is_trakt_group, b.is_trakt_group) {
|
||||
(true, false) => Some(Ordering::Less), // Trakt categories come first
|
||||
(false, true) => Some(Ordering::Greater), // Non-Trakt categories come after
|
||||
_ => None, // Both are Trakt or both are not Trakt, use other sorting criteria
|
||||
}
|
||||
}
|
||||
|
||||
fn playlistgroup_comparator(a: &PlaylistGroup, b: &PlaylistGroup, group_sort: &ConfigSortGroup, match_as_ascii: bool) -> Ordering {
|
||||
// Prioritize Trakt categories first
|
||||
if let Some(ordering) = trakt_priority_comparator(a, b) {
|
||||
return ordering;
|
||||
}
|
||||
|
||||
let value_a = if match_as_ascii { deunicode(&a.title) } else { a.title.to_string() };
|
||||
let value_b = if match_as_ascii { deunicode(&b.title) } else { b.title.to_string() };
|
||||
|
||||
@@ -120,6 +133,11 @@ pub(in crate::processing::processor) fn sort_playlist(target: &ConfigTarget, new
|
||||
let match_as_ascii = sort.match_as_ascii;
|
||||
if let Some(group_sort) = &sort.groups {
|
||||
new_playlist.sort_by(|a, b| playlistgroup_comparator(a, b, group_sort, match_as_ascii));
|
||||
} else {
|
||||
// Even without specific group sorting, prioritize Trakt categories then alphabetical
|
||||
new_playlist.sort_by(|a, b| {
|
||||
trakt_priority_comparator(a, b).unwrap_or_else(|| a.title.cmp(&b.title))
|
||||
});
|
||||
}
|
||||
if let Some(channel_sorts) = &sort.channels {
|
||||
for channel_sort in channel_sorts {
|
||||
@@ -132,6 +150,11 @@ pub(in crate::processing::processor) fn sort_playlist(target: &ConfigTarget, new
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No sort configuration at all - still prioritize Trakt categories then alphabetical
|
||||
new_playlist.sort_by(|a, b| {
|
||||
trakt_priority_comparator(a, b).unwrap_or_else(|| a.title.cmp(&b.title))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ fn create_category_from_matches<'a>(
|
||||
title: String::from(group_title),
|
||||
channels: matched_items,
|
||||
xtream_cluster: cluster,
|
||||
is_trakt_group: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ async fn process_series_info(
|
||||
title: plg.title.clone(),
|
||||
channels: group_series,
|
||||
xtream_cluster: XtreamCluster::Series,
|
||||
is_trakt_group: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user