diff --git a/CHANGELOG.md b/CHANGELOG.md index d51300ed..fc7c48d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +* Updated the documentation to specify ISO-639-1 language codes. +* Added `market` parameter to `album` and `albums` to address ([#753](https://github.com/plamere/spotipy/issues/753) // Add your changes here and then delete this line diff --git a/spotipy/client.py b/spotipy/client.py index 4ad4b2d9..3ac5c45d 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -144,7 +144,7 @@ def __init__( See urllib3 https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html :param language: The language parameter advertises what language the user prefers to see. - See ISO-639 language code: https://www.loc.gov/standards/iso639-2/php/code_list.php + See ISO-639-1 language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes """ self.prefix = "https://api.spotify.com/v1/" self._auth = auth @@ -420,15 +420,19 @@ def artist_related_artists(self, artist_id): trid = self._get_id("artist", artist_id) return self._get("artists/" + trid + "/related-artists") - def album(self, album_id): + def album(self, album_id, market=None): """ returns a single album given the album's ID, URIs or URL Parameters: - album_id - the album ID, URI or URL + - market - an ISO 3166-1 alpha-2 country code """ trid = self._get_id("album", album_id) - return self._get("albums/" + trid) + if market is not None: + return self._get("albums/" + trid + '?market=' + market) + else: + return self._get("albums/" + trid) def album_tracks(self, album_id, limit=50, offset=0, market=None): """ Get Spotify catalog information about an album's tracks @@ -446,15 +450,19 @@ def album_tracks(self, album_id, limit=50, offset=0, market=None): "albums/" + trid + "/tracks/", limit=limit, offset=offset, market=market ) - def albums(self, albums): + def albums(self, albums, market=None): """ returns a list of albums given the album IDs, URIs, or URLs Parameters: - albums - a list of album IDs, URIs or URLs + - market - an ISO 3166-1 alpha-2 country code """ tlist = [self._get_id("album", a) for a in albums] - return self._get("albums/?ids=" + ",".join(tlist)) + if market is not None: + return self._get("albums/?ids=" + ",".join(tlist) + '&market=' + market) + else: + return self._get("albums/?ids=" + ",".join(tlist)) def show(self, show_id, market=None): """ returns a single show given the show's ID, URIs or URL @@ -1483,8 +1491,8 @@ def featured_playlists( Parameters: - locale - The desired language, consisting of a lowercase ISO - 639 language code and an uppercase ISO 3166-1 alpha-2 country - code, joined by an underscore. + 639-1 alpha-2 language code and an uppercase ISO 3166-1 alpha-2 + country code, joined by an underscore. - country - An ISO 3166-1 alpha-2 country code. @@ -1533,7 +1541,7 @@ def category(self, category_id, country=None, locale=None): - category_id - The Spotify category ID for the category. - country - An ISO 3166-1 alpha-2 country code. - - locale - The desired language, consisting of an ISO 639 + - locale - The desired language, consisting of an ISO 639-1 alpha-2 language code and an ISO 3166-1 alpha-2 country code, joined by an underscore. """ @@ -1548,7 +1556,7 @@ def categories(self, country=None, locale=None, limit=20, offset=0): Parameters: - country - An ISO 3166-1 alpha-2 country code. - - locale - The desired language, consisting of an ISO 639 + - locale - The desired language, consisting of an ISO 639-1 alpha-2 language code and an ISO 3166-1 alpha-2 country code, joined by an underscore.