Updated documentation about ISO-639 language codes and address issue #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
This commit is contained in:
ivyadam 2022-06-18 15:18:59 -07:00 committed by GitHub
parent 14ee53eacd
commit 5175f19851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -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

View File

@ -144,7 +144,7 @@ class Spotify(object):
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,14 +420,18 @@ class Spotify(object):
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)
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):
@ -446,14 +450,18 @@ class Spotify(object):
"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]
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):
@ -1483,8 +1491,8 @@ class Spotify(object):
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 @@ class Spotify(object):
- 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 @@ class Spotify(object):
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.