From a4cfd839464460d262e7dc219c7568490f05166b Mon Sep 17 00:00:00 2001 From: dnlruiz <91227557+dnlruiz@users.noreply.github.com> Date: Sat, 18 Jun 2022 15:26:43 -0700 Subject: [PATCH] show_featured_artists.py and update publishing docs (#821) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * show_featured_artists.py and update publishing docs * Don't update version Co-authored-by: Stéphane Bruckert --- CHANGELOG.md | 13 +++++++++---- examples/show_featured_artists.py | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 examples/show_featured_artists.py diff --git a/CHANGELOG.md b/CHANGELOG.md index fc7c48d..1b66f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,16 @@ 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 +### Added + +* Added `market` parameter to `album` and `albums` to address ([#753](https://github.com/plamere/spotipy/issues/753) +* Added 'show_featured_artists.py' to 'examples'. + +### Fixed + +* Updated the documentation to specify ISO-639-1 language codes. +* Fix `AttributeError` for `text` attribute of the `Response` object ## [2.20.0] - 2022-06-18 @@ -18,7 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed URI handling in `client.Spotify._get_id()` to remove qureies if provided by error. * Added a new parameter to `RedisCacheHandler` to allow custom keys (instead of the default `token_info` key) * Simplify check for existing token in `RedisCacheHandler` -* Fix `AttributeError` for `text` attribute of the `Response` object ### Changed * Removed Python 3.5 and added Python 3.9 in Github Action diff --git a/examples/show_featured_artists.py b/examples/show_featured_artists.py new file mode 100644 index 0000000..0e01dc6 --- /dev/null +++ b/examples/show_featured_artists.py @@ -0,0 +1,27 @@ +# Shows all artists featured on an album + +# usage: featured_artists.py spotify:album:[album urn] + +from spotipy.oauth2 import SpotifyClientCredentials +import sys +import spotipy +from pprint import pprint + +if len(sys.argv) > 1: + urn = sys.argv[1] +else: + urn = 'spotify:album:5yTx83u3qerZF7GRJu7eFk' + +sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials()) +album = sp.album(urn) + +featured_artists = set() + +items = album['tracks']['items'] + +for item in items: + for ele in item['artists']: + if 'name' in ele: + featured_artists.add(ele['name']) + +pprint(featured_artists)