Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 79f4495

Browse files
authored
fix: use updated login endpoint (#10)
1 parent e2cf54f commit 79f4495

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

monstercat/catalog_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestBrowseCatalog_DefaultOptions(t *testing.T) {
1212
catalog, err := client.BrowseCatalog()
1313
assert.NoError(t, err)
1414
assert.NotEmpty(t, catalog.Data)
15-
assert.Len(t, catalog.Data, 10)
15+
assert.LessOrEqual(t, len(catalog.Data), 10) // the api sometimes skips entries without filling them up at the end
1616
assert.NotEqual(t, 0, catalog.Total)
1717
assert.True(t, catalog.HasNextPage())
1818
}

monstercat/login.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ func (client *Client) Login(email string, password string) error {
2323
}
2424
defer response.Body.Close()
2525

26-
if response.StatusCode != http.StatusNoContent {
27-
return ErrorInvalidCredentials
26+
if response.StatusCode != http.StatusOK {
27+
if response.StatusCode == http.StatusBadRequest {
28+
return ErrorInvalidCredentials
29+
}
30+
return fmt.Errorf("unexpected status code: %d", response.StatusCode)
2831
}
2932

3033
for _, cookie := range response.Cookies() {

monstercat/monstercat.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package monstercat
33
import "fmt"
44

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

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

1111
authenticationCookieName = "cid"
1212
)

0 commit comments

Comments
 (0)