Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation about ISO-639 language codes and address issue #753 #800

Merged
merged 3 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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)

### Added
* Added `RedisCacheHandler`, a cache handler that stores the token info in Redis.
Expand Down
26 changes: 17 additions & 9 deletions spotipy/client.py
Original file line number Diff line number Diff line change
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