1use serde::{Deserialize, Serialize};
2
3use chrono::Duration;
4use std::collections::HashMap;
5
6use crate::{
7 custom_serde::duration_ms, CopyrightType, DatePrecision, EpisodeId, Image, Page, ShowId,
8};
9
10#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
12pub struct Copyright {
13 pub text: String,
14 #[serde(rename = "type")]
15 pub _type: CopyrightType,
16}
17
18#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
20pub struct SimplifiedShow {
21 pub available_markets: Vec<String>,
22 pub copyrights: Vec<Copyright>,
23 pub description: String,
24 pub explicit: bool,
25 pub external_urls: HashMap<String, String>,
26 pub href: String,
27 pub id: ShowId<'static>,
28 pub images: Vec<Image>,
29 pub is_externally_hosted: Option<bool>,
30 pub languages: Vec<String>,
31 pub media_type: String,
32 pub name: String,
33 pub publisher: String,
34}
35
36#[derive(Deserialize)]
38pub struct SeversalSimplifiedShows {
39 pub shows: Vec<SimplifiedShow>,
40}
41
42#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
44pub struct Show {
45 pub added_at: String,
46 pub show: SimplifiedShow,
47}
48
49#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
51pub struct FullShow {
52 pub available_markets: Vec<String>,
53 pub copyrights: Vec<Copyright>,
54 pub description: String,
55 pub explicit: bool,
56 pub episodes: Page<SimplifiedEpisode>,
57 pub external_urls: HashMap<String, String>,
58 pub href: String,
59 pub id: ShowId<'static>,
60 pub images: Vec<Image>,
61 pub is_externally_hosted: Option<bool>,
62 pub languages: Vec<String>,
63 pub media_type: String,
64 pub name: String,
65 pub publisher: String,
66}
67
68#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
70pub struct SimplifiedEpisode {
71 pub audio_preview_url: Option<String>,
72 pub description: String,
73 #[serde(with = "duration_ms", rename = "duration_ms")]
74 pub duration: Duration,
75 pub explicit: bool,
76 pub external_urls: HashMap<String, String>,
77 pub href: String,
78 pub id: EpisodeId<'static>,
79 pub images: Vec<Image>,
80 pub is_externally_hosted: bool,
81 pub is_playable: bool,
82 #[deprecated(note = "This `language` field is deprecated and might be \
83 removed in the future by Spotify. Please use the languages field \
84 instead")]
85 pub language: String,
86 pub languages: Vec<String>,
87 pub name: String,
88 pub release_date: String,
89 pub release_date_precision: DatePrecision,
90 pub resume_point: Option<ResumePoint>,
91}
92
93#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
95pub struct FullEpisode {
96 pub audio_preview_url: Option<String>,
97 pub description: String,
98 #[serde(with = "duration_ms", rename = "duration_ms")]
99 pub duration: Duration,
100 pub explicit: bool,
101 pub external_urls: HashMap<String, String>,
102 pub href: String,
103 pub id: EpisodeId<'static>,
104 pub images: Vec<Image>,
105 pub is_externally_hosted: bool,
106 pub is_playable: bool,
107 #[deprecated(note = "This `language` field is deprecated and might be \
108 removed in the future by Spotify. Please use the languages field \
109 instead")]
110 pub language: String,
111 pub languages: Vec<String>,
112 pub name: String,
113 pub release_date: String,
114 pub release_date_precision: DatePrecision,
115 pub resume_point: Option<ResumePoint>,
116 pub show: SimplifiedShow,
117}
118
119#[derive(Deserialize)]
121pub struct EpisodesPayload {
122 pub episodes: Vec<FullEpisode>,
123}
124
125#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
127pub struct ResumePoint {
128 pub fully_played: bool,
129 #[serde(with = "duration_ms", rename = "resume_position_ms")]
130 pub resume_position: Duration,
131}