aboutsummaryrefslogtreecommitdiff
path: root/server/src/compat/jellyfin/models.rs
blob: 6a6845555354224b4f0910a3e34c3c8b3c4dd08a (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
    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 serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::BTreeMap;

#[derive(Debug, Serialize, Deserialize)]
pub(super) enum JellyfinItemType {
    AudioBook,
    Movie,
    BoxSet,
    Book,
    Photo,
    PhotoAlbum,
    TvChannel,
    LiveTvProgram,
    Video,
    Audio,
    MusicAlbum,
    CollectionFolder,
}

#[derive(Debug, Clone, Serialize)]
pub(super) enum JellyfinMediaStreamType {
    Video,
    Audio,
    Subtitle,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(super) struct JellyfinMediaStream {
    pub codec: String,
    pub time_base: String,
    pub video_range: String,
    pub video_range_type: String,
    pub audio_spatial_format: String,
    pub display_title: String,
    pub is_interlaced: bool,
    pub is_avc: bool,
    pub bit_rate: usize,
    pub bit_depth: usize,
    pub ref_frames: usize,
    pub is_default: bool,
    pub is_forced: bool,
    pub is_hearing_impaired: bool,
    pub height: Option<u64>,
    pub width: Option<u64>,
    pub average_frame_rate: Option<f64>,
    pub real_frame_rate: Option<f64>,
    pub reference_frame_rate: Option<f64>,
    pub profile: String,
    pub r#type: JellyfinMediaStreamType,
    pub aspect_ratio: String,
    pub index: usize,
    pub is_external: bool,
    pub is_text_subtitle_stream: bool,
    pub supports_external_stream: bool,
    pub pixel_format: String,
    pub level: usize,
    pub is_anamorphic: bool,
    pub channel_layout: Option<String>,
    pub channels: Option<usize>,
    pub sample_rate: Option<f64>,
    pub localized_default: String,
    pub localized_external: String,
}

#[derive(Debug, Clone, Serialize)]
pub(super) enum JellyfinMediaSourceProtocol {
    File,
}
#[derive(Debug, Clone, Serialize)]
pub(super) enum JellyfinMediaSourceType {
    Default,
}

#[derive(Debug, Clone, Serialize)]
pub(super) enum JellyfinVideoType {
    VideoFile,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(super) struct JellyfinMediaSource {
    pub protocol: JellyfinMediaSourceProtocol,
    pub id: String,
    pub path: String,
    pub r#type: JellyfinMediaSourceType,
    pub container: String,
    pub size: usize,
    pub name: String,
    pub is_remote: bool,
    pub e_tag: String,
    pub run_time_ticks: f64,
    pub read_at_native_framerate: bool,
    pub ignore_dts: bool,
    pub ignore_index: bool,
    pub gen_pts_input: bool,
    pub supports_transcoding: bool,
    pub supports_direct_stream: bool,
    pub supports_direct_play: bool,
    pub is_infinite_stream: bool,
    pub use_most_compatible_transcoding_profile: bool,
    pub requires_opening: bool,
    pub requires_closing: bool,
    pub requires_looping: bool,
    pub supports_probing: bool,
    pub video_type: JellyfinVideoType,
    pub media_streams: Vec<JellyfinMediaStream>,
    pub media_attachments: Vec<()>,
    pub formats: Vec<()>,
    pub bitrate: usize,
    pub required_http_headers: BTreeMap<(), ()>,
    pub transcoding_sub_protocol: String,
    pub default_audio_stream_index: usize,
    pub default_subtitle_stream_index: usize,
    pub has_segments: bool,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(super) struct JellyfinItem {
    pub name: String,
    pub server_id: String,
    pub id: String,
    pub e_tag: String,
    pub date_created: String,
    pub can_delete: bool,
    pub can_download: bool,
    pub preferred_metadata_language: String,
    pub preferred_metadata_country_code: String,
    pub sort_name: String,
    pub forced_sort_name: String,
    pub external_urls: Vec<()>,
    pub enable_media_source_display: bool,
    pub custom_rating: String,
    pub channel_id: Option<String>,
    pub overview: String,
    pub taglines: Vec<String>,
    pub genres: Vec<()>,
    pub play_access: Option<String>,
    pub remote_trailers: Vec<()>,
    pub provider_ids: BTreeMap<(), ()>,
    pub is_folder: bool,
    pub parent_id: String,
    pub r#type: JellyfinItemType,
    pub people: Vec<JellyfinPerson>,
    pub studios: Vec<JellyfinStudio>,
    pub genre_items: Vec<()>,
    pub local_trailer_count: usize,
    pub special_feature_count: usize,
    pub child_count: usize,
    pub locked_fields: Vec<()>,
    pub lock_data: bool,
    pub tags: Vec<String>,
    pub user_data: Value,
    pub display_preferences_id: String,
    pub primary_image_aspect_ratio: f64,
    pub collection_type: String,
    pub image_tags: BTreeMap<String, String>,
    pub backdrop_image_tags: Vec<String>,
    pub location_type: Option<String>,
    pub media_type: String,
    pub video_type: Option<String>,
    pub container: Option<String>,
    pub run_time_ticks: Option<i64>,
    pub media_sources: Option<Vec<JellyfinMediaSource>>,
    pub media_streams: Option<Vec<JellyfinMediaStream>>,
    pub path: Option<String>,
}

#[derive(Debug, Serialize)]
pub(super) enum JellyfinPersonType {
    Actor,
    // Writer,
    // Producer,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(super) struct JellyfinPerson {
    pub name: String,
    pub id: String,
    pub role: String,
    pub r#type: JellyfinPersonType,
    pub primary_image_tag: String,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub(super) struct JellyfinStudio {
    pub name: String,
    pub id: String,
}