@@ -8,6 +8,64 @@ import com.adamratzman.spotify.utils.Market
88import kotlinx.serialization.SerialName
99import kotlinx.serialization.Serializable
1010
11+ /* *
12+ * An episode (podcast) on Spotify
13+ *
14+ * @param album The album on which the track appears. The album object includes a link in
15+ * href to full information about the album.
16+ * @param artists The artists who performed the track. Each artist object includes a link in href
17+ * to more detailed information about the artist.
18+ * @property availableMarkets A list of the countries in which the track can be played, identified by their ISO 3166-1 alpha-2 code.
19+ * @param discNumber The disc number (usually 1 unless the album consists of more than one disc).
20+ * @param durationMs The track length in milliseconds.
21+ *
22+ * @param explicit Whether or not the track has explicit lyrics ( true = yes it does; false = no it does not OR unknown).
23+ * @param isLocal Whether or not the track is from a local file.
24+ * @param isPlayable Part of the response when Track Relinking is applied. If true , the track is playable in the
25+ * given market. Otherwise false.
26+ * @param name The name of the track.
27+ * @param popularity The popularity of the track. The value will be between 0 and 100, with 100 being the most
28+ * popular. The popularity of a track is a value between 0 and 100, with 100 being the most popular. The popularity
29+ * is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how
30+ * recent those plays are. Generally speaking, songs that are being played a lot now will have a higher popularity
31+ * than songs that were played a lot in the past. Duplicate tracks (e.g. the same track from a single and an album)
32+ * are rated independently. Artist and album popularity is derived mathematically from track popularity. Note that
33+ * the popularity value may lag actual popularity by a few days: the value is not updated in real time.
34+ * @param previewUrl A link to a 30 second preview (MP3 format) of the track. Can be null.
35+ * @param track Whether this episode is also a track.
36+ * @param trackNumber The number of the track. If an album has several discs, the track number is the number on the specified disc.
37+ * @param type The object type: “episode”.
38+ *
39+ */
40+ @Serializable
41+ public data class PodcastEpisodeTrack (
42+ val album : SimpleAlbum ,
43+ val artists : List <SimpleArtist >,
44+ @SerialName(" available_markets" ) private val availableMarketsString : List <String > = listOf(),
45+ @SerialName(" disc_number" ) val discNumber : Int ,
46+ @SerialName(" duration_ms" ) val durationMs : Int ,
47+ val episode : Boolean? = null ,
48+ val explicit : Boolean ,
49+ @SerialName(" external_urls" ) override val externalUrlsString : Map <String , String >,
50+ @SerialName(" external_ids" ) private val externalIdsString : Map <String , String > = hashMapOf(),
51+ override val href : String ,
52+ override val id : String ,
53+ @SerialName(" is_local" ) val isLocal : Boolean? = null ,
54+ @SerialName(" is_playable" ) val isPlayable : Boolean = true ,
55+ val name : String ,
56+ val popularity : Int ,
57+ @SerialName(" preview_url" ) val previewUrl : String? = null ,
58+ val track : Boolean? = null ,
59+ @SerialName(" track_number" ) val trackNumber : Int ,
60+ override val type : String ,
61+ override val uri : PlayableUri ,
62+ override val linkedTrack : LinkedTrack ? = null
63+ ) : RelinkingAvailableResponse(), Playable {
64+ val availableMarkets: List <Market > get() = availableMarketsString.map { Market .valueOf(it) }
65+
66+ val externalIds: List <ExternalId > get() = externalIdsString.map { ExternalId (it.key, it.value) }
67+ }
68+
1169/* *
1270 * An episode (podcast) on Spotify
1371 *
@@ -30,7 +88,7 @@ import kotlinx.serialization.Serializable
3088@Serializable
3189public data class Episode (
3290 @SerialName(" audio_preview_url" ) val audioPreviewUrl : String? = null ,
33- val description : String ,
91+ val description : String? = null ,
3492 @SerialName(" duration_ms" ) val durationMs : Int ,
3593 val explicit : Boolean ,
3694 @SerialName(" external_urls" ) override val externalUrlsString : Map <String , String >,
@@ -47,9 +105,9 @@ public data class Episode(
47105 @SerialName(" release_date_precision" ) val releaseDatePrecisionString : String ,
48106 @SerialName(" resume_point" ) val resumePoint : ResumePoint ? = null ,
49107 val show : SimpleShow ,
50- override val type : String ,
108+ val type : String ,
51109 override val uri : EpisodeUri
52- ) : CoreObject(), Playable {
110+ ) : CoreObject() {
53111 val releaseDate: ReleaseDate get() = getReleaseDate(releaseDateString)
54112
55113 @Suppress(" DEPRECATION" )
@@ -80,7 +138,7 @@ public data class Episode(
80138@Serializable
81139public data class SimpleEpisode (
82140 @SerialName(" audio_preview_url" ) val audioPreviewUrl : String? = null ,
83- val description : String ,
141+ val description : String? = null ,
84142 @SerialName(" duration_ms" ) val durationMs : Int ,
85143 val explicit : Boolean ,
86144 @SerialName(" external_urls" ) override val externalUrlsString : Map <String , String >,
@@ -96,22 +154,23 @@ public data class SimpleEpisode(
96154 @SerialName(" release_date" ) private val releaseDateString : String ,
97155 @SerialName(" release_date_precision" ) val releaseDatePrecisionString : String ,
98156 @SerialName(" resume_point" ) val resumePoint : ResumePoint ? = null ,
99- override val type : String ,
100- override val uri : EpisodeUri
101- ) : CoreObject(), Playable {
157+ val type : String ,
158+ override val uri : SpotifyUri
159+ ) : CoreObject() {
102160 val releaseDate: ReleaseDate get() = getReleaseDate(releaseDateString)
103161
104162 @Suppress(" DEPRECATION" )
105163 val languages: List <Locale >
106164 get() = (language?.let { showLanguagesPrivate + it } ? : showLanguagesPrivate)
107- .map { Locale .valueOf(it.replace(" -" , " _" )) }
165+ .map { Locale .valueOf(it.replace(" -" , " _" )) }
108166
109167 /* *
110168 * Converts this [SimpleEpisode] into a full [Episode] object
111169 *
112170 * @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
113171 */
114- public suspend fun toFullEpisode (market : Market ? = null): Episode ? = (api as ? SpotifyClientApi )?.episodes?.getEpisode(id, market)
172+ public suspend fun toFullEpisode (market : Market ? = null): Episode ? =
173+ (api as ? SpotifyClientApi )?.episodes?.getEpisode(id, market)
115174}
116175
117176/* *
0 commit comments