Skip to content

Commit

Permalink
Expose getStreamURL for use elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
tystuyfzand committed Aug 22, 2020
1 parent e074941 commit 0dcd24a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ func (c *Client) GetStream(video *Video, format *Format) (*http.Response, error)

// GetStreamContext returns the HTTP response for a specific format with a context
func (c *Client) GetStreamContext(ctx context.Context, video *Video, format *Format) (*http.Response, error) {
url, err := c.getStreamURL(ctx, video, format)
url, err := c.GetStreamURLContext(ctx, video, format)
if err != nil {
return nil, err
}

return c.httpGet(ctx, url)
}

func (c *Client) getStreamURL(ctx context.Context, video *Video, format *Format) (string, error) {
func (c *Client) GetStreamURL(video *Video, format *Format) (string, error) {
return c.GetStreamURLContext(context.Background(), video, format)
}

func (c *Client) GetStreamURLContext(ctx context.Context, video *Video, format *Format) (string, error) {
if format.URL != "" {
return format.URL, nil
}
Expand Down
2 changes: 1 addition & 1 deletion video_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestDownload_Regular(t *testing.T) {
format = &video.Formats[0]
}

url, err := testClient.getStreamURL(ctx, video, format)
url, err := testClient.GetStreamURLContext(ctx, video, format)
require.NoError(err)
require.NotEmpty(url)
})
Expand Down

0 comments on commit 0dcd24a

Please sign in to comment.