Skip to content

Commit

Permalink
Merge pull request #24 from WillyReyno/patch-3
Browse files Browse the repository at this point in the history
Add methods for getCatalogSongs & getCatalogAlbums
  • Loading branch information
PouleR authored Aug 20, 2024
2 parents 26064b0 + 97af9df commit 4d41289
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/AppleMusicAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ public function getCatalogAlbum(string $storefront, string $albumId, array $incl

return $this->client->apiRequest('GET', $requestUrl);
}

/**
* Fetch one or more albums by using their identifiers.
* https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_albums
*
* @param string $storefront An iTunes Store territory, specified by an ISO 3166 alpha-2 country code.
* @param string $albumIds The unique identifiers for the albums. The maximum fetch limit is 100.
* @param array $include A list of additional relationships to include in the fetch.
*
* @return array|object
*
* @throws AppleMusicAPIException
*/
public function getCatalogAlbums(string $storefront, string $albumIds, array $include = [])
{
$requestUrl = sprintf('catalog/%s/albums', $storefront);

$requestUrl .= '?' . urldecode(http_build_query(['ids' => $albumIds, 'include' => implode(',', $include)]));

return $this->client->apiRequest('GET', $requestUrl);
}

/**
* Fetch albums by a UPC.
Expand Down Expand Up @@ -215,6 +236,27 @@ public function getCatalogSong(string $storefront, string $songId, array $includ
return $this->client->apiRequest('GET', $requestUrl);
}

/**
* Fetch one or more songs by using their identifiers.
* https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_songs_by_id
*
* @param string $storefront An iTunes Store territory, specified by an ISO 3166 alpha-2 country code.
* @param string $songIds The unique identifiers for the songs. The maximum fetch limit is 300.
* @param array $include A list of additional relationships to include in the fetch.
*
* @return array|object
*
* @throws AppleMusicAPIException
*/
public function getCatalogSongs(string $storefront, string $songIds, array $include = [])
{
$requestUrl = sprintf('catalog/%s/songs', $storefront);

$requestUrl .= '?' . urldecode(http_build_query(['ids' => $songIds, 'include' => implode(',', $include)]));

return $this->client->apiRequest('GET', $requestUrl);
}

/**
* Fetch songs by an ISRC.
* https://developer.apple.com/documentation/applemusicapi/get_multiple_catalog_songs_by_isrc
Expand Down

0 comments on commit 4d41289

Please sign in to comment.