From 1736c64b311ba7b9054ef65220c4d85fe28ae884 Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 15 Apr 2024 14:36:05 -0400 Subject: [PATCH] Changed variable names to be more specific --- chat.go | 4 ++-- chat_test.go | 2 +- client.go | 20 ++++++++++---------- livestream.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/chat.go b/chat.go index 18d4491..3b64484 100644 --- a/chat.go +++ b/chat.go @@ -50,11 +50,11 @@ func (c *Client) ChatInfo(reload bool) (*ChatInfo, error) { } func (c *Client) getChatInfo() (*ChatInfo, error) { - if c.StreamUrl == "" { + if c.LiveStreamUrl == "" { return nil, fmt.Errorf("stream url is empty") } - resp, err := c.getWebpage(c.StreamUrl) + resp, err := c.getWebpage(c.LiveStreamUrl) if err != nil { return nil, fmt.Errorf("error getting stream webpage: %v", err) } diff --git a/chat_test.go b/chat_test.go index d84eb04..0e0c73d 100644 --- a/chat_test.go +++ b/chat_test.go @@ -24,7 +24,7 @@ func TestChatInfo(t *testing.T) { t.Skipf("Set %s to run this test.", liveUrlEnvVar) } - client, err := NewClient(NewClientOptions{StreamUrl: url}) + client, err := NewClient(NewClientOptions{LiveStreamUrl: url}) if err != nil { t.Fatalf("Want NewClient err = nil, got: %v", err) } diff --git a/client.go b/client.go index 499c23a..71b25d3 100644 --- a/client.go +++ b/client.go @@ -23,12 +23,12 @@ const ( ) type Client struct { - httpClient *http.Client - chatInfo *ChatInfo - chatStream *ChatStream - chatStreamMu sync.Mutex - StreamKey string - StreamUrl string + httpClient *http.Client + chatInfo *ChatInfo + chatStream *ChatStream + chatStreamMu sync.Mutex + ApiKey string + LiveStreamUrl string } func (c *Client) cookies() ([]*http.Cookie, error) { @@ -53,9 +53,9 @@ func (c *Client) PrintCookies() error { } type NewClientOptions struct { - Cookies []*http.Cookie `json:"cookies"` - StreamKey string `json:"stream_key"` - StreamUrl string `json:"stream_url"` + Cookies []*http.Cookie `json:"cookies"` + ApiKey string `json:"stream_key"` + LiveStreamUrl string `json:"stream_url"` } 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 &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) { diff --git a/livestream.go b/livestream.go index a36d109..72abd2f 100644 --- a/livestream.go +++ b/livestream.go @@ -95,7 +95,7 @@ type LivestreamResponse struct { func (c *Client) Request() (*LivestreamResponse, error) { hcl := http.Client{Timeout: 30 * time.Second} - resp, err := hcl.Get(c.StreamKey) + resp, err := hcl.Get(c.ApiKey) if err != nil { return nil, pkgErr("http Get request returned error", err) }