spotify_web_api/model/
shows.rs

1use super::{Copyright, ExternalUrls, Image, ItemType, Market, Page, SimplifiedEpisode};
2use serde::{Deserialize, Serialize};
3
4/// Full show (podcast) information from the Spotify catalog.
5///
6/// Contains complete details about a show including its episodes
7/// (when the `page_items` feature is enabled), description, publisher,
8/// and available markets.
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10pub struct Show {
11    /// A list of the countries in which the show can be played, identified by their [ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
12    #[cfg(feature = "markets")]
13    #[serde(skip_serializing_if = "Vec::is_empty", default)]
14    pub available_markets: Vec<Market>,
15
16    /// The copyright statements of the show.
17    pub copyrights: Vec<Copyright>,
18
19    /// A description of the show. HTML tags are stripped away from this field,
20    /// use `html_description` field in case HTML tags are needed.
21    pub description: String,
22
23    /// A description of the show. This field may contain HTML tags.
24    pub html_description: String,
25
26    /// Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown).
27    pub explicit: bool,
28
29    /// External URLs for this show.
30    pub external_urls: ExternalUrls,
31
32    /// A link to the Web API endpoint providing full details of the show.
33    pub href: String,
34
35    /// The Spotify ID for the show.
36    pub id: String,
37
38    /// The cover art for the show in various sizes, widest first.
39    pub images: Vec<Image>,
40
41    /// True if all of the show’s episodes are hosted outside of Spotify’s CDN.
42    pub is_externally_hosted: bool,
43
44    /// A list of the languages used in the episode, identified by their [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639) code.
45    pub languages: Vec<String>,
46
47    /// The media type of the show.
48    pub media_type: String,
49
50    /// The name of the show.
51    pub name: String,
52
53    /// The publisher of the show.
54    pub publisher: String,
55
56    /// The object type.
57    ///
58    /// Allowed values: "show"
59    #[serde(rename = "type")]
60    pub type_: ItemType,
61
62    /// The [Spotify URI](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids) for the show.
63    pub uri: String,
64
65    /// The total number of episodes in the show.
66    pub total_episodes: usize,
67
68    /// The episodes of the show.
69    #[cfg(feature = "page_items")]
70    pub episodes: Page<SimplifiedEpisode>,
71}
72
73/// Simplified show (podcast) information with basic details only.
74///
75/// A lighter version of [`Show`] that omits the episodes page.
76/// Commonly returned when shows are nested within other objects like episodes.
77#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
78pub struct SimplifiedShow {
79    /// A list of the countries in which the show can be played, identified by their [ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
80    #[cfg(feature = "markets")]
81    #[serde(skip_serializing_if = "Vec::is_empty", default)]
82    pub available_markets: Vec<Market>,
83
84    /// The copyright statements of the show.
85    pub copyrights: Vec<Copyright>,
86
87    /// A description of the show. HTML tags are stripped away from this field,
88    /// use `html_description` field in case HTML tags are needed.
89    pub description: String,
90
91    /// A description of the show. This field may contain HTML tags.
92    pub html_description: String,
93
94    /// Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown).
95    pub explicit: bool,
96
97    /// External URLs for this show.
98    pub external_urls: ExternalUrls,
99
100    /// A link to the Web API endpoint providing full details of the show.
101    pub href: String,
102
103    /// The Spotify ID for the show.
104    pub id: String,
105
106    /// The cover art for the show in various sizes, widest first.
107    pub images: Vec<Image>,
108
109    /// True if all of the show’s episodes are hosted outside of Spotify’s CDN.
110    pub is_externally_hosted: bool,
111
112    /// A list of the languages used in the episode, identified by their [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639) code.
113    pub languages: Vec<String>,
114
115    /// The media type of the show.
116    pub media_type: String,
117
118    /// The name of the show.
119    pub name: String,
120
121    /// The publisher of the show.
122    pub publisher: String,
123
124    /// The object type.
125    ///
126    /// Allowed values: "show"
127    #[serde(rename = "type")]
128    pub type_: ItemType,
129
130    /// The [Spotify URI](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids) for the show.
131    pub uri: String,
132
133    /// The total number of episodes in the show.
134    pub total_episodes: usize,
135}
136
137impl From<Show> for SimplifiedShow {
138    fn from(show: Show) -> Self {
139        Self {
140            #[cfg(feature = "markets")]
141            available_markets: show.available_markets,
142            copyrights: show.copyrights,
143            description: show.description,
144            html_description: show.html_description,
145            explicit: show.explicit,
146            external_urls: show.external_urls,
147            href: show.href,
148            id: show.id,
149            images: show.images,
150            is_externally_hosted: show.is_externally_hosted,
151            languages: show.languages,
152            media_type: show.media_type,
153            name: show.name,
154            publisher: show.publisher,
155            type_: show.type_,
156            uri: show.uri,
157            total_episodes: show.total_episodes,
158        }
159    }
160}
161
162/// A show saved to the current user's library.
163///
164/// Contains the timestamp when the show was saved and the show details.
165#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
166pub struct SavedShow {
167    /// The date and time the show was saved. Timestamps are returned in ISO 8601 format as Coordinated Universal Time (UTC)
168    /// with a zero offset: YYYY-MM-DDTHH:MM:SSZ. If the time is imprecise (for example, the date/time of an album release),
169    /// an additional field indicates the precision; see for example, `release_date` in an album object.
170    pub added_at: String,
171
172    /// Information about the show.
173    pub show: SimplifiedShow,
174}
175
176/// Spotify catalog information for several shows.
177#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
178pub struct Shows {
179    pub shows: Vec<SimplifiedShow>,
180}
181
182#[cfg(test)]
183mod tests {
184    use super::*;
185
186    #[test]
187    fn show() {
188        let json = r#"
189        {
190			"available_markets": ["US"],
191			"copyrights": [
192				{
193					"text": "string",
194					"type": "C"
195				}
196			],
197			"description": "string",
198			"html_description": "string",
199			"explicit": false,
200			"external_urls": {
201				"spotify": "string"
202			},
203			"href": "string",
204			"id": "string",
205			"images": [
206				{
207					"url": "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228",
208					"height": 300,
209					"width": 300
210				}
211			],
212			"is_externally_hosted": false,
213			"languages": ["string"],
214			"media_type": "string",
215			"name": "string",
216			"publisher": "string",
217			"type": "show",
218			"uri": "string",
219			"total_episodes": 0,
220			"episodes": {
221				"href": "https://api.spotify.com/v1/me/shows?offset=0&limit=20",
222				"limit": 20,
223				"next": "https://api.spotify.com/v1/me/shows?offset=1&limit=1",
224				"offset": 0,
225				"previous": "https://api.spotify.com/v1/me/shows?offset=1&limit=1",
226				"total": 4,
227				"items": [
228					{
229						"audio_preview_url": "https://p.scdn.co/mp3-preview/2f37da1d4221f40b9d1a98cd191f4d6f1646ad17",
230						"description": "A Spotify podcast sharing fresh insights on important topics of the moment—in a way only Spotify can. You’ll hear from experts in the music, podcast and tech industries as we discover and uncover stories about our work and the world around us.",
231						"html_description": "<p>A Spotify podcast sharing fresh insights on important topics of the moment—in a way only Spotify can. You’ll hear from experts in the music, podcast and tech industries as we discover and uncover stories about our work and the world around us.</p>",
232						"duration_ms": 1686230,
233						"explicit": false,
234						"external_urls": {
235							"spotify": "string"
236						},
237						"href": "https://api.spotify.com/v1/episodes/5Xt5DXGzch68nYYamXrNxZ",
238						"id": "5Xt5DXGzch68nYYamXrNxZ",
239						"images": [
240							{
241								"url": "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228",
242								"height": 300,
243								"width": 300
244							}
245						],
246						"is_externally_hosted": false,
247						"is_playable": false,
248						"language": "en",
249						"languages": ["fr", "en"],
250						"name": "Starting Your Own Podcast: Tips, Tricks, and Advice From Anchor Creators",
251						"release_date": "1981-12-15",
252						"release_date_precision": "day",
253						"resume_point": {
254							"fully_played": false,
255							"resume_position_ms": 0
256						},
257						"type": "episode",
258						"uri": "spotify:episode:0zLhl3WsOCQHbe1BPTiHgr",
259						"restrictions": {
260							"reason": "string"
261						}
262					}
263				]
264			}
265		}
266        "#;
267
268        crate::test::assert_deserialized!(Show, json);
269    }
270
271    #[test]
272    fn simplified_show() {
273        let json = r#"
274        {
275			"available_markets": ["US"],
276			"copyrights": [
277				{
278					"text": "string",
279					"type": "C"
280				}
281			],
282			"description": "string",
283			"html_description": "string",
284			"explicit": false,
285			"external_urls": {
286				"spotify": "string"
287			},
288			"href": "string",
289			"id": "string",
290			"images": [
291				{
292					"url": "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228",
293					"height": 300,
294					"width": 300
295				}
296			],
297			"is_externally_hosted": false,
298			"languages": ["string"],
299			"media_type": "string",
300			"name": "string",
301			"publisher": "string",
302			"type": "show",
303			"uri": "string",
304			"total_episodes": 0
305        }
306        "#;
307
308        crate::test::assert_deserialized!(SimplifiedShow, json);
309    }
310}