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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
mod feature;
pub mod library;

pub use self::feature::Feature;
use self::library::ContentDirectory;
use serde::Deserialize;
use serde_plain::derive_fromstr_from_deserialize;
use serde_with::{formats::CommaSeparator, serde_as, StringWithSeparator};
use time::OffsetDateTime;

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
pub struct Action {
    pub id: String,
    pub key: String,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(tag = "type", rename_all = "camelCase")]
pub struct GridChannelFilter {
    pub key: String,
    pub title: String,
    pub genre_rating_key: String,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum MediaProviderFeature {
    Content {
        key: String,
        #[serde(rename = "Directory")]
        directory: Vec<ContentDirectory>,
    },
    Search {
        key: String,
    },
    Match {
        key: String,
    },
    Metadata {
        key: String,
    },
    Rate {
        key: String,
    },
    ImageTranscoder {
        key: String,
    },
    Promoted {
        key: String,
    },
    ContinueWatching {
        key: String,
    },
    Actions {
        key: String,
        #[serde(rename = "Action")]
        actions: Vec<Action>,
    },
    Playlist {
        key: String,
        flavor: String,
    },
    PlayQueue {
        key: String,
        flavor: String,
    },
    #[serde(rename = "collection")]
    Collections {
        key: String,
    },
    #[serde(rename_all = "camelCase")]
    Timeline {
        key: String,
        scrobble_key: String,
        unscrobble_key: String,
    },
    Manage,
    #[serde(rename = "queryParser")]
    QueryParser,
    Subscribe {
        flavor: String,
    },
    Grid {
        key: String,
        #[serde(rename = "GridChannelFilter")]
        grid_channel_filter: Vec<GridChannelFilter>,
    },
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum MediaProviderProtocol {
    Stream,
    Download,
    #[serde(rename = "livetv")]
    LiveTv,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    Unknown,
}

derive_fromstr_from_deserialize!(MediaProviderProtocol);

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum MediaProviderType {
    Video,
    Audio,
    Photo,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    Unknown,
}

derive_fromstr_from_deserialize!(MediaProviderType);

#[serde_as]
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct MediaProvider {
    pub identifier: String,
    pub id: Option<u32>,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, MediaProviderProtocol>")]
    pub protocols: Vec<MediaProviderProtocol>,
    pub title: String,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, MediaProviderType>")]
    pub types: Vec<MediaProviderType>,
    #[serde(rename = "Feature")]
    pub features: Vec<MediaProviderFeature>,
    #[serde(rename = "parentID")]
    pub parent_id: Option<u32>,
    pub provider_identifier: Option<String>,
    pub epg_source: Option<String>,
    pub friendly_name: Option<String>,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub enum StartState {
    StartingPlugins,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    Other,
}

#[serde_as]
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct Server {
    pub size: u32,
    pub allow_camera_upload: bool,
    pub allow_channel_access: bool,
    pub allow_media_deletion: Option<bool>,
    pub allow_sharing: bool,
    pub allow_sync: bool,
    pub allow_tuners: bool,
    pub background_processing: bool,
    pub certificate: Option<bool>,
    pub companion_proxy: bool,
    pub country_code: Option<String>,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, Diagnostics>")]
    pub diagnostics: Vec<Diagnostics>,
    pub event_stream: bool,
    pub friendly_name: String,
    pub livetv: u8,
    pub machine_identifier: String,
    pub music_analysis: Option<u8>,
    pub my_plex: bool,
    pub my_plex_mapping_state: MappingState,
    pub my_plex_mapping_error: Option<MappingError>,
    pub my_plex_signin_state: MyPlexSignInState,
    pub my_plex_subscription: bool,
    pub my_plex_username: Option<String>,
    pub offline_transcode: Option<u8>,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, Feature>")]
    pub owner_features: Vec<Feature>,
    pub photo_auto_tag: bool,
    pub platform: String,
    pub platform_version: String,
    pub plugin_host: bool,
    pub push_notifications: bool,
    pub read_only_libraries: bool,
    pub start_state: Option<StartState>,
    #[serde(rename = "streamingBrainABRVersion")]
    pub streaming_brain_abr_version: u8,
    pub streaming_brain_version: u8,
    pub sync: bool,
    pub transcoder_active_video_sessions: u8,
    pub transcoder_audio: bool,
    pub transcoder_lyrics: bool,
    pub transcoder_subtitles: bool,
    pub transcoder_video: bool,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, u32>")]
    pub transcoder_video_bitrates: Vec<u32>,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, u8>")]
    pub transcoder_video_qualities: Vec<u8>,
    #[serde_as(as = "StringWithSeparator::<CommaSeparator, u16>")]
    pub transcoder_video_resolutions: Vec<u16>,
    #[serde(with = "time::serde::timestamp")]
    pub updated_at: OffsetDateTime,
    pub updater: bool,
    pub version: String,
    pub voice_search: bool,
    #[serde(rename = "MediaProvider")]
    pub media_providers: Vec<MediaProvider>,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "lowercase")]
pub enum Diagnostics {
    Logs,
    Databases,
    StreamingLogs,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    UnknownValue,
}

derive_fromstr_from_deserialize!(Diagnostics);

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub enum MappingState {
    Unknown,
    Wating,
    Mapped,
    Failed,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    UnknownValue,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub enum MappingError {
    Badauth,
    Unreachable,
    #[serde(rename = "myplexgone")]
    MyplexGone,
    #[serde(rename = "publisherror")]
    PublishError,
    #[serde(rename = "doublenat")]
    DoubleNat,
    #[serde(rename = "jumboframes")]
    JumboFrames,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    UnknownValue,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub enum MyPlexSignInState {
    Unknown,
    None,
    Invalid,
    Ok,
    #[cfg(not(feature = "tests_deny_unknown_fields"))]
    #[serde(other)]
    UnknownValue,
}