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

Commit 8fe5efb

Browse files
committed
fix: replace removed release download with new track download
1 parent ed9360b commit 8fe5efb

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

monstercat/download.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
)
99

10-
// DownloadFormat describes in what kind of formats we can download a release
10+
// DownloadFormat describes in what kind of formats we can download a catalog item
1111
type DownloadFormat string
1212

1313
// define all known download formats
@@ -17,13 +17,13 @@ const (
1717
DownloadReleaseFormatWAV = "wav"
1818
)
1919

20-
// DownloadRelease downloads the given release as ZIP file in the requested format and stores it at the given path
21-
func (client Client) DownloadRelease(release Release, downloadFormat DownloadFormat, downloadPath string) error {
20+
// DownloadCatalogItem downloads the given catalog item in the requested format and stores it at the given path
21+
func (client Client) DownloadCatalogItem(catalogItem CatalogItem, downloadFormat DownloadFormat, downloadPath string) error {
2222
if !client.IsLoggedIn() {
2323
return ErrorClientNotLoggedIn
2424
}
2525

26-
request, err := http.NewRequest("GET", fmt.Sprintf(endpointDownloadRelease, release.ID, downloadFormat), http.NoBody)
26+
request, err := http.NewRequest("GET", fmt.Sprintf(endpointDownloadCatalogItem, catalogItem.Release.ID, catalogItem.ID, downloadFormat), http.NoBody)
2727
if err != nil {
2828
return err
2929
}
@@ -58,5 +58,3 @@ func (client Client) DownloadRelease(release Release, downloadFormat DownloadFor
5858

5959
return nil
6060
}
61-
62-
// TODO: add download function for a single catalog item

monstercat/download_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func Test_DownloadRelease(t *testing.T) {
1010
client := NewClient()
1111

12-
err := client.DownloadRelease(Release{}, DownloadReleaseFormatMP3, "./file.zip")
12+
err := client.DownloadCatalogItem(CatalogItem{}, DownloadReleaseFormatMP3, "./file.mp3")
1313
assert.Error(t, err)
1414
assert.Equal(t, ErrorClientNotLoggedIn, err)
1515
}

monstercat/monstercat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const (
66
endpointLogin = "https://www.monstercat.com/api/sign-in"
77
endpointCatalog = "https://www.monstercat.com/api/catalog/browse"
88

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

1111
authenticationCookieName = "cid"
1212
)

0 commit comments

Comments
 (0)