Skip to content

Commit

Permalink
v2.0.3: Add turnstile field, fail on non-200 status
Browse files Browse the repository at this point in the history
  • Loading branch information
lostdusty committed Oct 14, 2024
1 parent 2e6a270 commit 7e0999e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gobalt.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ type CobaltInstance struct {
StartTime int64 `json:"startTime"`
API string `json:"api"`
FrontEnd string `json:"frontEnd"`
Turnstile bool `json:"turnstile"`
}

type Services struct {
Expand Down Expand Up @@ -372,8 +373,7 @@ func GetYoutubePlaylist(playlist string) (Playlist, error) {
return nil, err
}
if getUrls.StatusCode != 200 {
read, _ := io.ReadAll(getUrls.Body)
return nil, fmt.Errorf("%v\n%v", getUrls.Status, string(read))
return nil, fmt.Errorf("failed to get playlists: %v", getUrls.Status)
}

unmarshalBody, err := io.ReadAll(getUrls.Body)
Expand Down Expand Up @@ -404,5 +404,9 @@ func genericHttpRequest(url, method string, body io.Reader) (*http.Response, err
return nil, err
}

if response.StatusCode != 200 {
return nil, fmt.Errorf("request failed with %v", response.Status)
}

return response, nil
}

0 comments on commit 7e0999e

Please sign in to comment.