Changed variable names to be more specific

This commit is contained in:
tyler 2024-04-15 14:36:05 -04:00
parent 52b51727eb
commit 1736c64b31
4 changed files with 14 additions and 14 deletions

View file

@ -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)
}

View file

@ -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)
}

View file

@ -27,8 +27,8 @@ type Client struct {
chatInfo *ChatInfo
chatStream *ChatStream
chatStreamMu sync.Mutex
StreamKey string
StreamUrl string
ApiKey string
LiveStreamUrl string
}
func (c *Client) cookies() ([]*http.Cookie, error) {
@ -54,8 +54,8 @@ func (c *Client) PrintCookies() error {
type NewClientOptions struct {
Cookies []*http.Cookie `json:"cookies"`
StreamKey string `json:"stream_key"`
StreamUrl string `json:"stream_url"`
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) {

View file

@ -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)
}