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
use secrecy::SecretString;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use serde_repr::Deserialize_repr;
use serde_with::{json::JsonString, serde_as};
use std::collections::HashMap;
use time::OffsetDateTime;
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionSummary {
pub active: bool,
#[serde(with = "time::serde::rfc3339::option")]
pub subscribed_at: Option<OffsetDateTime>,
pub status: SubscriptionStatus,
pub payment_service: Option<String>,
pub plan: Option<String>,
pub features: Vec<crate::media_container::server::Feature>,
}
#[derive(Deserialize, Debug, Clone)]
pub enum SubscriptionStatus {
Active,
Inactive,
Canceled,
PendingCancellation,
Ended,
Lapsed,
#[serde(other)]
Unknown,
}
#[derive(Deserialize_repr, Debug, Clone)]
#[repr(u8)]
pub enum AutoSelectSubtitleMode {
ManuallySelected = 0,
ShownWithForeignAudio = 1,
AlwaysEnabled = 2,
#[serde(other)]
Unknown,
}
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct Profile {
pub auto_select_audio: bool,
pub auto_select_subtitle: AutoSelectSubtitleMode,
#[serde(deserialize_with = "bool_from_int")]
pub default_subtitle_accessibility: bool,
#[serde(deserialize_with = "bool_from_int")]
pub default_subtitle_forced: bool,
pub default_audio_language: Option<String>,
pub default_subtitle_language: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct Subscription {
pub id: Option<i32>,
pub mode: String,
pub state: String,
pub renews_at: Option<OffsetDateTime>,
pub ends_at: Option<OffsetDateTime>,
pub r#type: Option<String>,
pub transfer: Option<bool>,
pub billing: Option<Value>,
pub canceled: Option<bool>,
pub grace_period: Option<bool>,
pub on_hold: Option<bool>,
pub can_upgrade: Option<bool>,
pub can_reactivate: Option<bool>,
pub can_downgrade: Option<bool>,
pub can_convert: Option<bool>,
}
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
pub struct Service {
pub identifier: String,
pub endpoint: String,
pub token: Option<SecretString>,
pub secret: Option<SecretString>,
pub status: String,
}
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct MyPlexAccount {
pub id: u64,
pub uuid: String,
pub username: String,
pub friendly_name: String,
pub confirmed: bool,
pub title: String,
pub email: String,
pub thumb: String,
pub locale: Option<String>,
pub email_only_auth: bool,
pub has_password: bool,
pub cloud_sync_device: Option<String>,
pub auth_token: SecretString,
pub mailing_list_status: Option<String>,
pub mailing_list_active: bool,
pub scrobble_types: String,
pub pin: Option<String>,
pub subscription: SubscriptionSummary,
pub subscription_description: Option<String>,
pub restricted: bool,
pub home: bool,
pub guest: bool,
pub queue_email: Option<String>,
pub queue_uid: Option<HashMap<String, String>>,
pub home_size: i32,
pub max_home_size: i32,
#[serde(with = "time::serde::timestamp::option")]
pub remember_expires_at: Option<OffsetDateTime>,
pub profile: Profile,
pub entitlements: Vec<String>,
pub roles: Option<Vec<String>>,
pub services: Vec<Service>,
pub protected: bool,
pub country: String,
pub home_admin: bool,
pub ads_consent: Option<bool>,
#[serde(with = "time::serde::timestamp::option")]
pub ads_consent_set_at: Option<OffsetDateTime>,
#[serde(with = "time::serde::timestamp::option")]
pub ads_consent_reminder_at: Option<OffsetDateTime>,
pub anonymous: Option<bool>,
pub experimental_features: bool,
pub two_factor_enabled: bool,
pub backup_codes_created: bool,
#[serde(with = "time::serde::timestamp")]
pub joined_at: OffsetDateTime,
pub restriction_profile: Option<RestrictionProfile>,
pub mapped_restriction_profile: Option<RestrictionProfile>,
pub subscriptions: Option<Vec<Subscription>>,
pub past_subscriptions: Option<Vec<Subscription>>,
pub trials: Option<Vec<Subscription>>,
pub settings: Option<Vec<Settings>>,
pub custom_restrictions: Option<CustomRestrictions>,
pub providers: Option<Vec<String>>,
}
#[derive(Deserialize, Debug, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
pub struct CustomRestrictions {
pub all: Option<bool>,
pub movies: Option<bool>,
pub music: Option<bool>,
pub photos: Option<bool>,
pub television: Option<bool>,
}
#[derive(Debug, Deserialize, Clone)]
#[serde(tag = "id", rename_all = "camelCase")]
pub enum Settings {
Experience(ExperienceSettingsContainer),
#[serde(other)]
Unknown,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct ExperienceSettingsContainer {
pub hidden: bool,
#[serde(with = "time::serde::timestamp")]
pub updated_at: OffsetDateTime,
#[serde(flatten)]
pub settings: ExperienceSettingsFormat,
}
#[serde_as]
#[derive(Debug, Deserialize, Clone)]
#[serde(tag = "type", content = "value", rename_all = "camelCase")]
pub enum ExperienceSettingsFormat {
Json(#[serde_as(as = "JsonString")] ExperienceSettings),
#[serde(other)]
Unknown,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct ExperienceSettings {
pub auto_home_hubs_enabled: bool,
pub auto_pinned_providers: Vec<String>,
pub schema_version: i32,
pub home_settings: ExperienceHomeSettings,
pub sidebar_settings: ExperienceSidebarSettings,
pub reminders: Vec<String>,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct ExperienceHomeSettings {
pub settings_key: String,
pub hubs: Vec<String>,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct ExperienceSidebarSettings {
pub has_completed_setup: bool,
pub pinned_sources: Vec<SidebarSource>,
}
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "tests_deny_unknown_fields", serde(deny_unknown_fields))]
#[serde(rename_all = "camelCase")]
pub struct SidebarSource {
pub key: String,
pub source_type: String,
pub machine_identifier: String,
pub provider_identifier: String,
#[serde(rename = "directoryID")]
pub directory_id: String,
pub directory_icon: String,
pub title: String,
pub server_friendly_name: String,
pub provider_source_title: String,
pub is_cloud: bool,
pub is_full_owned_server: bool,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[serde(rename_all = "snake_case")]
pub enum RestrictionProfile {
LittleKid,
OlderKid,
Teen,
#[cfg(not(feature = "tests_deny_unknown_fields"))]
#[serde(other)]
Unknown,
}
fn bool_from_int<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
use serde::de::{self, Unexpected};
match u8::deserialize(deserializer)? {
0 => Ok(false),
1 => Ok(true),
other => Err(de::Error::invalid_value(
Unexpected::Unsigned(other as u64),
&"zero or one",
)),
}
}