Skip to content

Commit

Permalink
fix: use updated login endpoint (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
menzerath authored Mar 9, 2022
1 parent e2cf54f commit 79f4495
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion monstercat/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestBrowseCatalog_DefaultOptions(t *testing.T) {
catalog, err := client.BrowseCatalog()
assert.NoError(t, err)
assert.NotEmpty(t, catalog.Data)
assert.Len(t, catalog.Data, 10)
assert.LessOrEqual(t, len(catalog.Data), 10) // the api sometimes skips entries without filling them up at the end
assert.NotEqual(t, 0, catalog.Total)
assert.True(t, catalog.HasNextPage())
}
Expand Down
7 changes: 5 additions & 2 deletions monstercat/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ func (client *Client) Login(email string, password string) error {
}
defer response.Body.Close()

if response.StatusCode != http.StatusNoContent {
return ErrorInvalidCredentials
if response.StatusCode != http.StatusOK {
if response.StatusCode == http.StatusBadRequest {
return ErrorInvalidCredentials
}
return fmt.Errorf("unexpected status code: %d", response.StatusCode)
}

for _, cookie := range response.Cookies() {
Expand Down
6 changes: 3 additions & 3 deletions monstercat/monstercat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package monstercat
import "fmt"

const (
endpointLogin = "https://www.monstercat.com/api/sign-in"
endpointCatalog = "https://www.monstercat.com/api/catalog/browse"
endpointLogin = "https://player.monstercat.app/api/sign-in"
endpointCatalog = "https://player.monstercat.app/api/catalog/browse"

endpointDownloadCatalogItem = "https://www.monstercat.com/api/release/%s/track-download/%s?format=%s"
endpointDownloadCatalogItem = "https://player.monstercat.app/api/release/%s/track-download/%s?format=%s"

authenticationCookieName = "cid"
)
Expand Down

0 comments on commit 79f4495

Please sign in to comment.