Skip to content

Commit 50c47c2

Browse files
authored
Merge pull request #234 from coolbaluk/add_episode_endpoint
Add episode endpoint
2 parents 89c9506 + 560cb5d commit 50c47c2

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

show.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,21 @@ func (c *Client) SaveShowsForCurrentUser(ctx context.Context, ids []ID) error {
218218

219219
return c.execute(req, nil, http.StatusOK)
220220
}
221+
222+
// GetEpisode gets an episode from a show.
223+
// API reference: https://developer.spotify.com/documentation/web-api/reference/get-an-episode
224+
func (c *Client) GetEpisode(ctx context.Context, id string, opts ...RequestOption) (*EpisodePage, error) {
225+
spotifyURL := c.baseURL + "episodes/" + id
226+
if params := processOptions(opts...).urlParams.Encode(); params != "" {
227+
spotifyURL += "?" + params
228+
}
229+
230+
var result EpisodePage
231+
232+
err := c.get(ctx, spotifyURL, &result)
233+
if err != nil {
234+
return nil, err
235+
}
236+
237+
return &result, nil
238+
}

show_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,20 @@ func TestSaveShowsForCurrentUser_Errors(t *testing.T) {
6565
t.Fatal(err)
6666
}
6767
}
68+
69+
func TestGetEpisode(t *testing.T) {
70+
c, s := testClientFile(http.StatusOK, "test_data/get_episode.txt")
71+
defer s.Close()
72+
73+
id := "2DSKnz9Hqm1tKimcXqcMJD"
74+
r, err := c.GetEpisode(context.Background(), id)
75+
if err != nil {
76+
t.Fatal(err)
77+
}
78+
if r.ID.String() != id {
79+
t.Error("Invalid data:", r.ID)
80+
}
81+
if r.Type != "episode" {
82+
t.Error("Invalid data:", r.ID)
83+
}
84+
}

test_data/get_episode.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"audio_preview_url" : "https://p.scdn.co/mp3-preview/cac00fc7b28df9c607ef3f812b47ed3676e27a38",
3+
"description" : "Su is sitting out today, and I instead welcome Charlie Noyes and Georgios Konstantopoulos of Paradigm, one of the largest investment funds in crypto.   We cover a lot of ground in this episode, including: How Paradigm can so consistently identify and back the category-defining protocols and companies in crypto   MEV and how it can be mitigated, including some actionable advice on how you can avoid getting sandwich-attacked today  The new features and remaining challenges of Uniswap v3 Paradigm’s thesis for Cosmos and why each blockchain should adopt the IBC protocol   Whether Bitcoin's value proposition is still intact at a time where Bitcoin dominance is at an all-time low  Our personal “wishlists” for Bitcoin improvement proposals, and  whether Bitcoin will ever go to PoS   Listen to conversations between Su Zhu, the CEO and CIO of Three Arrows Capital, and Hasu, an experienced crypto researcher and writer. Together with occasional guests, we explore the transformative nature of trust-minimized currency and financial services. SUBSCRIBE to the Podcast Apple Podcast https://podcasts.apple.com/us/podcast/uncommon-core/id1517659188?uo=4 Spotify https://open.spotify.com/show/3vuV292Him90EjQ5YL4XIw Youtube https://podcasts.google.com/feed/aHR0cHM6Ly9hbmNob3IuZm0vcy8yNTc4ZDVhMC9wb2RjYXN0L3Jzcw== Other https://anchor.fm/uncommoncore FOLLOW on Twitter Su Zhu https://twitter.com/zhusu Hasu https://twitter.com/hasufl Our homepage and mailing list https://uncommoncore.co/podcast/ Transcripts, if available https://uncommoncore.co/blog/",
4+
"duration_ms" : 5485408,
5+
"explicit" : false,
6+
"external_urls" : {
7+
"spotify" : "https://open.spotify.com/episode/2DSKnz9Hqm1tKimcXqcMJD"
8+
},
9+
"href" : "https://api.spotify.com/v1/episodes/2DSKnz9Hqm1tKimcXqcMJD",
10+
"html_description" : "Su is sitting out today, and I instead welcome Charlie Noyes and Georgios Konstantopoulos of Paradigm, one of the largest investment funds in crypto.  \nWe cover a lot of ground in this episode, including:\n\n How Paradigm can so consistently identify and back the category-defining protocols and companies in crypto  \n MEV and how it can be mitigated, including some actionable advice on how you can avoid getting sandwich-attacked today \n The new features and remaining challenges of Uniswap v3\n Paradigm’s thesis for Cosmos and why each blockchain should adopt the IBC protocol  \n Whether Bitcoin's value proposition is still intact at a time where Bitcoin dominance is at an all-time low \n Our personal “wishlists” for Bitcoin improvement proposals, and \n whether Bitcoin will ever go to PoS  \n\nListen to conversations between Su Zhu, the CEO and CIO of Three Arrows Capital, and Hasu, an experienced crypto researcher and writer. Together with occasional guests, we explore the transformative nature of trust-minimized currency and financial services.\nSUBSCRIBE to the Podcast\nApple Podcast https://podcasts.apple.com/us/podcast/uncommon-core/id1517659188?uo=4\nSpotify https://open.spotify.com/show/3vuV292Him90EjQ5YL4XIw\nYoutube https://podcasts.google.com/feed/aHR0cHM6Ly9hbmNob3IuZm0vcy8yNTc4ZDVhMC9wb2RjYXN0L3Jzcw==\nOther https://anchor.fm/uncommoncore\nFOLLOW on Twitter\nSu Zhu https://twitter.com/zhusu\nHasu https://twitter.com/hasufl\nOur homepage and mailing list https://uncommoncore.co/podcast/\nTranscripts, if available https://uncommoncore.co/blog/",
11+
"id" : "2DSKnz9Hqm1tKimcXqcMJD",
12+
"images" : [ {
13+
"height" : 640,
14+
"url" : "https://i.scdn.co/image/ab6765630000ba8a05c1a052d1c08b04f32d5575",
15+
"width" : 640
16+
}, {
17+
"height" : 300,
18+
"url" : "https://i.scdn.co/image/ab67656300005f1f05c1a052d1c08b04f32d5575",
19+
"width" : 300
20+
}, {
21+
"height" : 64,
22+
"url" : "https://i.scdn.co/image/ab6765630000f68d05c1a052d1c08b04f32d5575",
23+
"width" : 64
24+
} ],
25+
"is_externally_hosted" : false,
26+
"is_playable" : true,
27+
"language" : "en",
28+
"languages" : [ "en" ],
29+
"name" : "#25: Paradigm's Thesis - with Charlie Noyes, Georgios Konstantopoulos and Hasu",
30+
"release_date" : "2021-05-18",
31+
"release_date_precision" : "day",
32+
"resume_point" : {
33+
"fully_played" : false,
34+
"resume_position_ms" : 5466000
35+
},
36+
"type" : "episode",
37+
"uri" : "spotify:episode:2DSKnz9Hqm1tKimcXqcMJD"
38+
}

0 commit comments

Comments
 (0)