Changed variable names to be more specific
This commit is contained in:
parent
52b51727eb
commit
1736c64b31
4
chat.go
4
chat.go
|
@ -50,11 +50,11 @@ func (c *Client) ChatInfo(reload bool) (*ChatInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) getChatInfo() (*ChatInfo, error) {
|
func (c *Client) getChatInfo() (*ChatInfo, error) {
|
||||||
if c.StreamUrl == "" {
|
if c.LiveStreamUrl == "" {
|
||||||
return nil, fmt.Errorf("stream url is empty")
|
return nil, fmt.Errorf("stream url is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.getWebpage(c.StreamUrl)
|
resp, err := c.getWebpage(c.LiveStreamUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting stream webpage: %v", err)
|
return nil, fmt.Errorf("error getting stream webpage: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestChatInfo(t *testing.T) {
|
||||||
t.Skipf("Set %s to run this test.", liveUrlEnvVar)
|
t.Skipf("Set %s to run this test.", liveUrlEnvVar)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := NewClient(NewClientOptions{StreamUrl: url})
|
client, err := NewClient(NewClientOptions{LiveStreamUrl: url})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Want NewClient err = nil, got: %v", err)
|
t.Fatalf("Want NewClient err = nil, got: %v", err)
|
||||||
}
|
}
|
||||||
|
|
10
client.go
10
client.go
|
@ -27,8 +27,8 @@ type Client struct {
|
||||||
chatInfo *ChatInfo
|
chatInfo *ChatInfo
|
||||||
chatStream *ChatStream
|
chatStream *ChatStream
|
||||||
chatStreamMu sync.Mutex
|
chatStreamMu sync.Mutex
|
||||||
StreamKey string
|
ApiKey string
|
||||||
StreamUrl string
|
LiveStreamUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) cookies() ([]*http.Cookie, error) {
|
func (c *Client) cookies() ([]*http.Cookie, error) {
|
||||||
|
@ -54,8 +54,8 @@ func (c *Client) PrintCookies() error {
|
||||||
|
|
||||||
type NewClientOptions struct {
|
type NewClientOptions struct {
|
||||||
Cookies []*http.Cookie `json:"cookies"`
|
Cookies []*http.Cookie `json:"cookies"`
|
||||||
StreamKey string `json:"stream_key"`
|
ApiKey string `json:"stream_key"`
|
||||||
StreamUrl string `json:"stream_url"`
|
LiveStreamUrl string `json:"stream_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(opts NewClientOptions) (*Client, error) {
|
func NewClient(opts NewClientOptions) (*Client, error) {
|
||||||
|
@ -64,7 +64,7 @@ func NewClient(opts NewClientOptions) (*Client, error) {
|
||||||
return nil, pkgErr("error creating http client", err)
|
return nil, pkgErr("error creating http client", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Client{httpClient: cl, StreamKey: opts.StreamKey, StreamUrl: opts.StreamUrl}, nil
|
return &Client{httpClient: cl, ApiKey: opts.ApiKey, LiveStreamUrl: opts.LiveStreamUrl}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHttpClient(cookies []*http.Cookie) (*http.Client, error) {
|
func newHttpClient(cookies []*http.Cookie) (*http.Client, error) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ type LivestreamResponse struct {
|
||||||
|
|
||||||
func (c *Client) Request() (*LivestreamResponse, error) {
|
func (c *Client) Request() (*LivestreamResponse, error) {
|
||||||
hcl := http.Client{Timeout: 30 * time.Second}
|
hcl := http.Client{Timeout: 30 * time.Second}
|
||||||
resp, err := hcl.Get(c.StreamKey)
|
resp, err := hcl.Get(c.ApiKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, pkgErr("http Get request returned error", err)
|
return nil, pkgErr("http Get request returned error", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue