Skip to content

Commit

Permalink
Updated documentation about ISO-639 language codes and address issue #…
Browse files Browse the repository at this point in the history
…753 (#800)

* Updated references to ISO 639 standard to clarify that the ISO 639-1 alpha-2 standard is used.

* Added `market` parameter to `album` and `albums`

* fix formatting change
  • Loading branch information
ivyadam committed Jun 18, 2022
1 parent 14ee53e commit 5175f19
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
26 changes: 17 additions & 9 deletions spotipy/client.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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.
Expand Down

0 comments on commit 5175f19

Please sign in to comment.