spotify_rs/model/
show.rs

1use chrono::{DateTime, Utc};
2use serde::Deserialize;
3use spotify_rs_macros::docs;
4
5use super::*;
6
7/// A show.
8#[derive(Clone, Debug, Deserialize, PartialEq)]
9#[docs]
10pub struct Show {
11    #[serde(default)]
12    pub available_markets: Vec<String>,
13    pub copyrights: Vec<String>,
14    pub description: String,
15    pub html_description: String,
16    pub explicit: bool,
17    pub external_urls: ExternalUrls,
18    pub href: String,
19    pub id: String,
20    pub images: Vec<Image>,
21    /// Whether or not all of the show's episodes are hosted outside of Spotify's
22    /// CDN.
23    pub is_externally_hosted: Option<bool>,
24    pub languages: Vec<String>,
25    pub media_type: String,
26    pub name: String,
27    pub publisher: String,
28    pub r#type: String,
29    pub uri: String,
30    /// The amount of episodes the show contains.
31    pub total_episodes: u32,
32    /// The episodes of the show.
33    pub episodes: Page<SimplifiedEpisode>,
34}
35
36/// A simplified show, missing some details, that is usually obtained
37/// through endpoints not specific to shows. The `href` field may be
38/// used to get a full show.
39#[derive(Clone, Debug, Deserialize, PartialEq)]
40#[docs(name = "show")]
41pub struct SimplifiedShow {
42    #[serde(default)]
43    pub available_markets: Vec<String>,
44    pub copyrights: Vec<String>,
45    pub description: String,
46    pub html_description: String,
47    pub explicit: bool,
48    pub external_urls: ExternalUrls,
49    pub href: String,
50    pub id: String,
51    pub images: Vec<Image>,
52    /// Whether or not all of the show's episodes are hosted outside of Spotify's
53    /// CDN.
54    pub is_externally_hosted: Option<bool>,
55    pub languages: Vec<String>,
56    pub media_type: String,
57    pub name: String,
58    pub publisher: String,
59    pub r#type: String,
60    pub uri: String,
61    /// The amount of episodes the show contains.
62    pub total_episodes: u32,
63}
64
65/// A show saved by a user.
66#[derive(Clone, Debug, Deserialize, PartialEq)]
67pub struct SavedShow {
68    /// The date and time the show was saved.
69    pub added_at: DateTime<Utc>,
70    /// The show itself.
71    pub show: SimplifiedShow,
72}
73
74// Used only to deserialize JSON responses with arrays that are named objects.
75#[derive(Clone, Debug, Deserialize, PartialEq)]
76pub(crate) struct Shows {
77    pub(crate) shows: Vec<Option<SimplifiedShow>>,
78}
79
80/// A show episode.
81#[derive(Clone, Debug, Deserialize, PartialEq)]
82#[docs]
83pub struct Episode {
84    /// The URL for a 30 second MP3 preview of the chapter.
85    ///
86    /// **Note:** This attribute has been deprecated by Spotify. It continues to work for
87    /// applications already using the extended mode in the API.
88    ///
89    /// You can read more about this [here](https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api).
90    pub audio_preview_url: Option<String>,
91    pub description: String,
92    pub html_description: String,
93    pub duration_ms: u32,
94    pub explicit: bool,
95    pub external_urls: ExternalUrls,
96    pub href: String,
97    pub id: String,
98    pub images: Vec<Image>,
99    /// Whether or not the episode is hosted outside of Spotify's CDN.
100    pub is_externally_hosted: bool,
101    pub is_playable: bool,
102    pub languages: Vec<String>,
103    pub name: String,
104    pub release_date: String,
105    pub release_date_precision: DatePrecision,
106    pub resume_point: Option<ResumePoint>,
107    pub r#type: String,
108    pub uri: String,
109    /// Included in the response when a content restriction is applied.
110    pub restrictions: Option<Restriction>,
111    /// The show to which the episode belongs.
112    pub show: SimplifiedShow,
113}
114
115/// A simplified episode, missing some details, that is usually obtained
116/// through endpoints not specific to episodes. The `href` field may be
117/// used to get a full episode.
118#[derive(Clone, Debug, Deserialize, PartialEq)]
119#[docs(name = "episode")]
120pub struct SimplifiedEpisode {
121    /// The URL for a 30 second MP3 preview of the chapter.
122    ///
123    /// **Note:** This attribute has been deprecated by Spotify. It continues to work for
124    /// applications already using the extended mode in the API.
125    ///
126    /// You can read more about this [here](https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api).
127    pub audio_preview_url: Option<String>,
128    pub description: String,
129    pub html_description: String,
130    pub duration_ms: u32,
131    pub explicit: bool,
132    pub external_urls: ExternalUrls,
133    pub href: String,
134    pub id: String,
135    pub images: Vec<Image>,
136    /// Whether or not the episode is hosted outside of Spotify's CDN.
137    pub is_externally_hosted: bool,
138    pub is_playable: bool,
139    pub languages: Vec<String>,
140    pub name: String,
141    pub release_date: String,
142    pub release_date_precision: DatePrecision,
143    pub resume_point: Option<ResumePoint>,
144    pub r#type: String,
145    pub uri: String,
146    /// Included in the response when a content restriction is applied.
147    pub restrictions: Option<Restriction>,
148}
149
150/// An episode saved by a user.
151#[derive(Clone, Debug, Deserialize, PartialEq)]
152pub struct SavedEpisode {
153    /// The date and time the episode was saved.
154    pub added_at: DateTime<Utc>,
155    /// The episode itself.
156    pub episode: Episode,
157}
158
159// Used only to deserialize JSON responses with arrays that are named objects.
160#[derive(Clone, Debug, Deserialize, PartialEq)]
161pub(crate) struct Episodes {
162    pub(crate) episodes: Vec<Option<Episode>>,
163}