diff --git a/CHANGELOG.md b/CHANGELOG.md index 8362463..b0cfbc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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. - Restructured the tutorial in `index.rst` to improve logical flow and made some minor edits. +- Updated _regex_spotify_url to ignore `/intl-` in Spotify links ### Fixed - Fixed unused description parameter in playlist creation example diff --git a/spotipy/client.py b/spotipy/client.py index 00850e5..610c79c 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -107,15 +107,19 @@ class Spotify: # numbers and even older ones seemed to have been allowed to freely pick this name. # # [1] https://www.iana.org/assignments/uri-schemes/prov/spotify - # [2] https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids + # [2] https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids _regex_spotify_uri = r'^spotify:(?:(?Ptrack|artist|album|playlist|show|episode|audiobook):(?P[0-9A-Za-z]+)|user:(?P[0-9A-Za-z]+):playlist:(?P[0-9A-Za-z]+))$' # noqa: E501 # Spotify URLs are defined at [1]. The assumption is made that they are all # pointing to open.spotify.com, so a regex is used to parse them as well, # instead of a more complex URL parsing function. + # Spotify recently added "/intl-" to their links. This change is undocumented. + # There is an assumption that the country code uses the ISO 3166-1 alpha-2 standard [2], + # but this has not been confirmed yet. Spotipy has no use for this, so it gets ignored. # - # [1] https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids - _regex_spotify_url = r'^(http[s]?:\/\/)?open.spotify.com\/(?Ptrack|artist|album|playlist|show|episode|user|audiobook)\/(?P[0-9A-Za-z]+)(\?.*)?$' # noqa: E501 + # [1] https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids + # [2] https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + _regex_spotify_url = r'^(http[s]?:\/\/)?open.spotify.com\/(intl-\w\w\/)?(?Ptrack|artist|album|playlist|show|episode|user|audiobook)\/(?P[0-9A-Za-z]+)(\?.*)?$' # noqa: E501 _regex_base62 = r'^[0-9A-Za-z]+$'