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

Codebase Refactor for v3 #961

Merged
merged 22 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f3d1192
Update changelog and setup to v3
stephanebruckert Mar 4, 2021
f7ae328
Fixed audio_features API wrapper function return structure (#653)
badfarmerjohn Mar 5, 2021
07fec53
V3 (#665)
Peter-Schorn Apr 10, 2021
4fe6350
Sync branches (#667)
stephanebruckert Apr 10, 2021
0b6ede6
Added `MemoryCacheHandler`, a cache handler that simply stores the to…
Peter-Schorn Apr 14, 2021
bc7343c
Fixed a bug in `CacheFileHandler.__init__`: The documentation says th…
Peter-Schorn Apr 14, 2021
aa9652f
Merge branch 'v3' into master
Peter-Schorn Apr 14, 2021
b6c3961
Merge pull request #1 from Peter-Schorn/master
Peter-Schorn Apr 14, 2021
bd80181
Renamed the `auth` parameter of `Spotify.__init__` to `access_token` …
Peter-Schorn Apr 14, 2021
8973fc2
Fixed lint issues
Peter-Schorn Apr 14, 2021
d7e8dd1
Merge pull request #671 from Peter-Schorn/v3
stephanebruckert Apr 14, 2021
4918305
Sync branches (#920)
stephanebruckert Dec 26, 2022
f005732
Make redis dependency optional (#869)
ahesford Dec 26, 2022
cc5260c
Codebase Refactor for v3
HighnessAtharva Apr 8, 2023
4fc4695
flake8 fixes
HighnessAtharva Apr 9, 2023
b04dadd
Merge branch 'v3_rebase_rebase' of github.com:spotipy-dev/spotipy int…
stephanebruckert Jan 15, 2025
742cdd9
Add back follow examples
stephanebruckert Jan 15, 2025
f8e4518
Add back missing oauth changes
stephanebruckert Jan 16, 2025
2058de1
pep8
stephanebruckert Jan 16, 2025
065d898
Fix tests
stephanebruckert Jan 16, 2025
e83bb06
More f-strings changes
stephanebruckert Jan 16, 2025
571f975
pep8
stephanebruckert Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 54 additions & 45 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,49 @@ Rebasing master onto v3 doesn't require a changelog update.

### Added

* `Scope` - An enum which contains all of the authorization scopes (see [here](https://github.com/plamere/spotipy/issues/652#issuecomment-797461311)).
- `Scope` - An enum which contains all of the authorization scopes (see [here](https://github.com/plamere/spotipy/issues/652#issuecomment-797461311)).

### Changed

* Made `CacheHandler` an abstract base class
* Modified the return structure of the `audio_features` function (wrapping the [Get Audio Features for Several Tracks](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-several-audio-features) API) to conform to the return structure of the similar methods listed below. The functions wrapping these APIs do not unwrap the single key JSON response, and this is currently the only function that does this.
* [Get Several Tracks](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-several-tracks)
* [Get Multiple Artists](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-multiple-artists)
* [Get Multiple Albums](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-multiple-albums)
* Renamed the `auth` parameter of `Spotify.__init__` to `access_token` for better clarity.
* Removed the `client_credentials_manager` and `oauth_manager` parameters because they are redundant.
* Replaced the `set_auth` and `auth_manager` properties with standard attributes.
- Made `CacheHandler` an abstract base class
- Modified the return structure of the `audio_features` function (wrapping the [Get Audio Features for Several Tracks](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-several-audio-features) API) to conform to the return structure of the similar methods listed below. The functions wrapping these APIs do not unwrap the single key JSON response, and this is currently the only function that does this.
- [Get Several Tracks](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-several-tracks)
- [Get Multiple Artists](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-multiple-artists)
- [Get Multiple Albums](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-multiple-albums)
- Renamed the `auth` parameter of `Spotify.__init__` to `access_token` for better clarity.
- Removed the `client_credentials_manager` and `oauth_manager` parameters because they are redundant.
- Replaced the `set_auth` and `auth_manager` properties with standard attributes.
- Replaced string concatenations and `str.format()` with f-strings

### Removed

* Removed the following deprecated methods from `Spotify`:
* `playlist_tracks`
* `user_playlist`
* `user_playlist_tracks`
* `user_playlist_change_details`
* `user_playlist_unfollow`
* `user_playlist_add_tracks`
* `user_playlist_replace_tracks`
* `user_playlist_reorder_tracks`
* `user_playlist_remove_all_occurrences_of_tracks`
* `user_playlist_remove_specific_occurrences_of_tracks`
* `user_playlist_follow_playlist`
* `user_playlist_is_following`

* Removed the deprecated `as_dict` parameter from the `get_access_token` method of `SpotifyOAuth` and `SpotifyPKCE`.
* Removed the deprecated `get_cached_token` and `_save_token_info` methods of `SpotifyOAuth` and `SpotifyPKCE`.
* Removed `SpotifyImplicitGrant`.
* Removed `prompt_for_user_token`.
- Removed the following deprecated methods from `Spotify`:
- `playlist_tracks`
- `user_playlist`
- `user_playlist_tracks`
- `user_playlist_change_details`
- `user_playlist_unfollow`
- `user_playlist_add_tracks`
- `user_playlist_replace_tracks`
- `user_playlist_reorder_tracks`
- `user_playlist_remove_all_occurrences_of_tracks`
- `user_playlist_remove_specific_occurrences_of_tracks`
- `user_playlist_follow_playlist`
- `user_playlist_is_following`

- Removed the deprecated `as_dict` parameter from the `get_access_token` method of `SpotifyOAuth` and `SpotifyPKCE`.
- Removed the deprecated `get_cached_token` and `_save_token_info` methods of `SpotifyOAuth` and `SpotifyPKCE`.
- Removed `SpotifyImplicitGrant`.
- Removed `prompt_for_user_token`.

## Unreleased [2.x.x]

### Added

- Added examples for audiobooks, shows and episodes methods to examples directory

### Fixed

- Fixed scripts in examples directory that didn't run correctly
- Updated documentation for `Client.current_user_top_artists` to indicate maximum number of artists limit

Expand All @@ -60,6 +63,7 @@ Rebasing master onto v3 doesn't require a changelog update.
## [2.25.0] - 2025-03-01

### Added

- Added unit tests for queue functions
- Added detailed function docstrings to 'util.py', including descriptions and special sections that lists arguments, returns, and raises.
- Updated order of instructions for Python and pip package manager installation in TUTORIAL.md
Expand All @@ -80,42 +84,50 @@ Rebasing master onto v3 doesn't require a changelog update.
- Added FAQ entry for inaccessible playlists

### Fixed

- Audiobook integration tests
- Edited docstrings for certain functions in client.py for functions that are no longer in use and have been replaced.
- `current_user_unfollow_playlist()` now supports playlist IDs, URLs, and URIs rather than previously where it only supported playlist IDs.

### Removed

- `mock` no longer listed as a test dependency. Only built-in `unittest.mock` is actually used.

## [2.24.0] - 2024-05-30

### Added

- Added `MemcacheCacheHandler`, a cache handler that stores the token info using pymemcache.
- Added support for audiobook endpoints: `get_audiobook`, `get_audiobooks`, and `get_audiobook_chapters`.
- Added integration tests for audiobook endpoints.
- Added `update` field to `current_user_follow_playlist`.

### Changed

- Fixed error obfuscation when Spotify class is being inherited and an error is raised in the Child's `__init__`
- Replaced `artist_albums(album_type=...)` with `artist_albums(include_groups=...)` due to an API change.
- Updated `_regex_spotify_url` to ignore `/intl-<countrycode>` in Spotify links
- Improved README, docs and examples

### Fixed

- Readthedocs build
- Split `test_current_user_save_and_usave_tracks` unit test

### Removed

- Drop support for EOL Python 3.7

## [2.23.0] - 2023-04-07

### Added

- Added optional `encoder_cls` argument to `CacheFileHandler`, which overwrite default encoder for token before writing to disk
- Integration tests for searching multiple types in multiple markets (non-user endpoints)
- Publish to PyPI action

### Fixed

- Fixed the regex for matching playlist URIs with the format spotify:user:USERNAME:playlist:PLAYLISTID.
- `search_markets` now factors the counts of all types in the `total` rather than just the first type ([#534](https://github.com/spotipy-dev/spotipy/issues/534))

Expand All @@ -124,7 +136,7 @@ Rebasing master onto v3 doesn't require a changelog update.
### Added

- Add alternative module installation instruction to README
- Added Comment to README - Getting Started for user to add URI to app in Spotify Developer Dashboard.
- Added Comment to README - Getting Started for user to add URI to app in Spotify Developer Dashboard.
- Added playlist_add_tracks.py to example folder

### Changed
Expand Down Expand Up @@ -197,22 +209,18 @@ Rebasing master onto v3 doesn't require a changelog update.
- Fixed a bug in the initializers for the auth managers that produced a spurious warning message if you provide a cache handler, and you set a value for the "SPOTIPY_CLIENT_USERNAME" environment variable.
- Use generated MIT license and fix license type in `pip show`

### Fixed

* Fixed a bug in `CacheFileHandler.__init__`: The documentation says that the username will be retrieved from the environment, but it wasn't.

## [2.18.0] - 2021-04-13

### Added

- Enabled using both short and long IDs for playlist_change_details
- Added a cache handler to `SpotifyClientCredentials`
- Added the following endpoints
- `Spotify.current_user_saved_episodes`
- `Spotify.current_user_saved_episodes_add`
- `Spotify.current_user_saved_episodes_delete`
- `Spotify.current_user_saved_episodes_contains`
- `Spotify.available_markets`
- `Spotify.current_user_saved_episodes`
- `Spotify.current_user_saved_episodes_add`
- `Spotify.current_user_saved_episodes_delete`
- `Spotify.current_user_saved_episodes_contains`
- `Spotify.available_markets`

### Changed

Expand Down Expand Up @@ -297,7 +305,7 @@ Rebasing master onto v3 doesn't require a changelog update.
- Support to test whether the current user is following certain
users or artists
- Proper replacements for all deprecated playlist endpoints
(See https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/ and below)
(See <https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/> and below)
- Allow for OAuth 2.0 authorization by instructing the user to open the URL in a browser instead of opening the browser.
- Reason for 403 error in SpotifyException
- Support for the PKCE Auth Flow
Expand Down Expand Up @@ -387,10 +395,10 @@ Rebasing master onto v3 doesn't require a changelog update.

- Client retry logic has changed as it now uses urllib3's `Retry` in conjunction with requests `Session`
- The session is customizable as it allows for:
- status_forcelist
- retries
- status_retries
- backoff_factor
- status_forcelist
- retries
- status_retries
- backoff_factor
- Spin up a local webserver to autofill authentication URL
- Use session in SpotifyAuthBase
- Logging used instead of print statements
Expand All @@ -405,9 +413,9 @@ Rebasing master onto v3 doesn't require a changelog update.
### Added

- Support for `add_to_queue`
- **Parameters:**
- track uri, id, or url
- device id. If None, then the active device is used.
- **Parameters:**
- track uri, id, or url
- device id. If None, then the active device is used.
- Add CHANGELOG and LICENSE to released package

## [2.9.0] - 2020-02-15
Expand Down Expand Up @@ -504,6 +512,7 @@ Rebasing master onto v3 doesn't require a changelog update.
### Changed

- Made instructions in the CONTRIBUTING.md file more clear such that it is easier to onboard and there are no conflicts with TUTORIAL.md

## [2.5.0] - 2020-01-11

Added follow and player endpoints
Expand Down
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $env:SPOTIPY_CLIENT_USERNAME="client_username_here"
$env:SPOTIPY_REDIRECT_URI="http://localhost:8080"
```

### Create virtual environment, install dependencies, run tests:
### Create virtual environment, install dependencies, run tests

```bash
$ virtualenv --python=python3 env
Expand Down Expand Up @@ -50,9 +50,9 @@ Don't forget to add a short description of your change in the [CHANGELOG](CHANGE

### Publishing (by maintainer)

- Bump version in setup.py
- Bump and date changelog
- Add to changelog:
- Bump version in setup.py
- Bump and date changelog
- Add to changelog:

## Unreleased
Add your changes below.
Expand All @@ -63,9 +63,8 @@ Don't forget to add a short description of your change in the [CHANGELOG](CHANGE

### Removed

- Commit changes
- Push tag to trigger PyPI build & release workflow
- Create github release https://github.com/plamere/spotipy/releases with the changelog content
- Commit changes
- Push tag to trigger PyPI build & release workflow
- Create github release <https://github.com/plamere/spotipy/releases> with the changelog content
for the version and a short name that describes the main addition
- Verify doc uses latest https://readthedocs.org/projects/spotipy/

- Verify doc uses latest <https://readthedocs.org/projects/spotipy/>
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotipy

##### Spotipy is a lightweight Python library for the [Spotify Web API](https://developer.spotify.com/documentation/web-api). With Spotipy you get full access to all of the music data provided by the Spotify platform.
##### Spotipy is a lightweight Python library for the [Spotify Web API](https://developer.spotify.com/documentation/web-api). With Spotipy you get full access to all of the music data provided by the Spotify platform

![Integration tests](https://github.com/spotipy-dev/spotipy/actions/workflows/integration_tests.yml/badge.svg?branch=master) [![Documentation Status](https://readthedocs.org/projects/spotipy/badge/?version=master)](https://spotipy.readthedocs.io/en/latest/?badge=master) [![Discord server](https://img.shields.io/discord/1244611850700849183?style=flat&logo=discord&logoColor=7289DA&color=7289DA)](https://discord.gg/HP6xcPsTPJ)

Expand All @@ -22,7 +22,7 @@ Spotipy supports all of the features of the Spotify Web API including access to
pip install spotipy
```

alternatively, for Windows users
alternatively, for Windows users

```bash
py -m pip install spotipy
Expand All @@ -38,7 +38,7 @@ pip install spotipy --upgrade

A full set of examples can be found in the [online documentation](http://spotipy.readthedocs.org/) and in the [Spotipy examples directory](https://github.com/plamere/spotipy/tree/master/examples).

To get started, [install spotipy](#installation), create a new account or log in on https://developers.spotify.com/. Go to the [dashboard](https://developer.spotify.com/dashboard), create an app and add your new ID and SECRET (ID and SECRET can be found on an app setting) to your environment ([step-by-step video](https://www.youtube.com/watch?v=kaBVN8uP358)):
To get started, [install spotipy](#installation), create a new account or log in on [developers.spotify.com](https://developers.spotify.com/). Go to the [dashboard](https://developer.spotify.com/dashboard), create an app and add your new ID and SECRET (ID and SECRET can be found on an app setting) to your environment ([step-by-step video](https://www.youtube.com/watch?v=kaBVN8uP358)):

### Example without user authentication

Expand All @@ -53,7 +53,9 @@ results = sp.search(q='weezer', limit=20)
for idx, track in enumerate(results['tracks']['items']):
print(idx, track['name'])
```

Expected result:

```
0 Island In The Sun
1 Say It Ain't So
Expand All @@ -65,7 +67,6 @@ Expected result:
19 Feels Like Summer
```


### Example with user authentication

A redirect URI must be added to your application at [My Dashboard](https://developer.spotify.com/dashboard/applications) to access user authenticated features.
Expand All @@ -84,13 +85,14 @@ for idx, item in enumerate(results['items']):
track = item['track']
print(idx, track['artists'][0]['name'], " – ", track['name'])
```

Expected result will be the list of music that you liked. For example if you liked Red and Sunflower, the result will be:

```
0 Post Malone – Sunflower - Spider-Man: Into the Spider-Verse
1 Taylor Swift – Red
```


## Reporting Issues

For common questions please check our [FAQ](FAQ.md).
Expand Down
Loading
Loading