11package spotify
22
33import (
4+ "net/url"
45 "strconv"
56 "strings"
67 "time"
@@ -20,7 +21,7 @@ type FullShow struct {
2021 SimpleShow
2122
2223 // A list of the show’s episodes.
23- Episodes EpisodePage `json:"episode "`
24+ Episodes SimpleEpisodePage `json:"episodes "`
2425}
2526
2627// SimpleShow contains basic data about a show.
@@ -166,3 +167,69 @@ func (e *EpisodePage) ReleaseDateTime() time.Time {
166167 year , _ := strconv .Atoi (e .ReleaseDate )
167168 return time .Date (year , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )
168169}
170+
171+ // GetShow retrieves information about a specific show.
172+ // API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-show
173+ func (c * Client ) GetShow (id string ) (* FullShow , error ) {
174+ return c .GetShowOpt (nil , id )
175+ }
176+
177+ // GetShowOpt is like GetShow while supporting an optional market parameter.
178+ // API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-show
179+ func (c * Client ) GetShowOpt (opt * Options , id string ) (* FullShow , error ) {
180+ spotifyURL := c .baseURL + "shows/" + id
181+ if opt != nil {
182+ v := url.Values {}
183+ if opt .Country != nil {
184+ v .Set ("market" , * opt .Country )
185+ }
186+ if params := v .Encode (); params != "" {
187+ spotifyURL += "?" + params
188+ }
189+ }
190+
191+ var result FullShow
192+
193+ err := c .get (spotifyURL , & result )
194+ if err != nil {
195+ return nil , err
196+ }
197+
198+ return & result , nil
199+ }
200+
201+ // GetShowEpisodes retrieves paginated episode information about a specific show.
202+ // API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-shows-episodes
203+ func (c * Client ) GetShowEpisodes (id string ) (* SimpleEpisodePage , error ) {
204+ return c .GetShowEpisodesOpt (nil , id )
205+ }
206+
207+ // GetShowEpisodesOpt is like GetShowEpisodes while supporting optional market, limit, offset parameters.
208+ // API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-shows-episodes
209+ func (c * Client ) GetShowEpisodesOpt (opt * Options , id string ) (* SimpleEpisodePage , error ) {
210+ spotifyURL := c .baseURL + "shows/" + id + "/episodes"
211+ if opt != nil {
212+ v := url.Values {}
213+ if opt .Country != nil {
214+ v .Set ("market" , * opt .Country )
215+ }
216+ if opt .Limit != nil {
217+ v .Set ("limit" , strconv .Itoa (* opt .Limit ))
218+ }
219+ if opt .Offset != nil {
220+ v .Set ("offset" , strconv .Itoa (* opt .Offset ))
221+ }
222+ if params := v .Encode (); params != "" {
223+ spotifyURL += "?" + params
224+ }
225+ }
226+
227+ var result SimpleEpisodePage
228+
229+ err := c .get (spotifyURL , & result )
230+ if err != nil {
231+ return nil , err
232+ }
233+
234+ return & result , nil
235+ }
0 commit comments