1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use crate::{url_enum, user::NodeUserData, Node, NodeKind};
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, sync::Arc, time::Duration};
type NodesWithUdata = Vec<(Arc<Node>, NodeUserData)>;
#[derive(Serialize, Deserialize)]
pub struct ApiNodeResponse {
pub parents: NodesWithUdata,
pub children: NodesWithUdata,
pub node: Arc<Node>,
pub userdata: NodeUserData,
}
#[derive(Serialize, Deserialize)]
pub struct ApiSearchResponse {
pub count: usize,
pub results: NodesWithUdata,
pub duration: Duration,
}
#[derive(Serialize, Deserialize)]
pub struct ApiItemsResponse {
pub count: usize,
pub pages: usize,
pub items: NodesWithUdata,
}
#[derive(Serialize, Deserialize)]
pub struct ApiHomeResponse {
pub toplevel: NodesWithUdata,
pub categories: Vec<(String, NodesWithUdata)>,
}
#[derive(Serialize, Deserialize)]
pub struct ApiStatsResponse {
pub kinds: BTreeMap<NodeKind, StatsBin>,
pub total: StatsBin,
}
#[derive(Default, Serialize, Deserialize)]
pub struct StatsBin {
pub runtime: f64,
pub size: u64,
pub count: usize,
pub max_runtime: (f64, String),
pub max_size: (u64, String),
}
#[derive(Debug, Default, Clone)]
pub struct NodeFilterSort {
pub sort_by: Option<SortProperty>,
pub filter_kind: Option<Vec<FilterProperty>>,
pub sort_order: Option<SortOrder>,
}
url_enum!(
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum FilterProperty {
FederationLocal = "fed_local",
FederationRemote = "fed_remote",
Watched = "watched",
Unwatched = "unwatched",
WatchProgress = "watch_progress",
KindMovie = "kind_movie",
KindVideo = "kind_video",
KindShortFormVideo = "kind_short_form_video",
KindMusic = "kind_music",
KindCollection = "kind_collection",
KindChannel = "kind_channel",
KindShow = "kind_show",
KindSeries = "kind_series",
KindSeason = "kind_season",
KindEpisode = "kind_episode",
}
);
url_enum!(
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum SortProperty {
ReleaseDate = "release_date",
Title = "title",
Index = "index",
Duration = "duration",
RatingRottenTomatoes = "rating_rt",
RatingMetacritic = "rating_mc",
RatingImdb = "rating_imdb",
RatingTmdb = "rating_tmdb",
RatingYoutubeViews = "rating_yt_views",
RatingYoutubeLikes = "rating_yt_likes",
RatingYoutubeFollowers = "rating_yt_followers",
RatingUser = "rating_user",
RatingLikesDivViews = "rating_loved",
}
);
url_enum!(
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum SortOrder {
Ascending = "ascending",
Descending = "descending",
}
);
|