move deser fn at the bottom of the file
@@ -16,40 +16,6 @@ use std::borrow::Cow;
use std::collections::HashMap;
use url::Url;
-fn deserialize_and_sort_videos<'de, D>(deserializer: D) -> Result<Vec<Video>, D::Error>
-where
- D: Deserializer<'de>,
-{
- let mut videos: Vec<Video> = Vec::<Video>::deserialize(deserializer)?;
- let some_sessons = videos.iter().any(|v| v.series_info.is_some());
-
- videos.sort_by(|a, b| {
- if let (Some(a), Some(b)) = (a.series_info.as_ref(), b.series_info.as_ref()) {
- let a_season = if a.season == 0 { u32::MAX } else { a.season };
- let b_season = if b.season == 0 { u32::MAX } else { b.season };
- a_season.cmp(&b_season).then(a.episode.cmp(&b.episode))
- } else if a.series_info.is_some() {
- std::cmp::Ordering::Less
- } else if b.series_info.is_some() {
- std::cmp::Ordering::Greater
- } else if let (Some(a), Some(b)) = (a.released, b.released) {
- if some_sessons {
- a.cmp(&b)
- } else {
- b.cmp(&a)
- }
- } else if a.released.is_some() {
- std::cmp::Ordering::Less
- } else if b.released.is_some() {
- std::cmp::Ordering::Greater
- } else {
- std::cmp::Ordering::Equal
- }
- });
-
- Ok(videos)
-}
-
#[derive(Clone, PartialEq, Deserialize)]
#[cfg_attr(debug_assertions, derive(Debug))]
#[cfg_attr(test, derive(Default))]
@@ -274,3 +240,37 @@ pub struct MetaItemBehaviorHints {
#[serde(flatten)]
pub other: HashMap<String, serde_json::Value>,
}
+
+fn deserialize_and_sort_videos<'de, D>(deserializer: D) -> Result<Vec<Video>, D::Error>
+where
+ D: Deserializer<'de>,
+{
+ let mut videos: Vec<Video> = Vec::<Video>::deserialize(deserializer)?;
+ let some_sessons = videos.iter().any(|v| v.series_info.is_some());
+
+ videos.sort_by(|a, b| {
+ if let (Some(a), Some(b)) = (a.series_info.as_ref(), b.series_info.as_ref()) {
+ let a_season = if a.season == 0 { u32::MAX } else { a.season };
+ let b_season = if b.season == 0 { u32::MAX } else { b.season };
+ a_season.cmp(&b_season).then(a.episode.cmp(&b.episode))
+ } else if a.series_info.is_some() {
+ std::cmp::Ordering::Less
+ } else if b.series_info.is_some() {
+ std::cmp::Ordering::Greater
+ } else if let (Some(a), Some(b)) = (a.released, b.released) {
+ if some_sessons {
+ a.cmp(&b)
+ } else {
+ b.cmp(&a)
+ }
+ } else if a.released.is_some() {
+ std::cmp::Ordering::Less
+ } else if b.released.is_some() {
+ std::cmp::Ordering::Greater
+ } else {
+ std::cmp::Ordering::Equal
+ }
+ });
+
+ Ok(videos)
+}
