[GH-ISSUE #1071] _regex_spotify_url needs update because of region specific path #633

Closed
opened 2026-02-28 00:00:24 +03:00 by kerem · 1 comment
Owner

Originally created by @Commandcracker on GitHub (Jan 14, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1071

Originally assigned to: @dieser-niko on GitHub.

github.com/spotipy-dev/spotipy@a14a28e10c/spotipy/client.py (L121C1-L121C173)

The URL has some additions in some regions (for me Germany)
https://open.spotify.com/intl-de/track/2Y0iGXY6m6immVb2ktbseM?si=22cad793e8e248fe
https://open.spotify.com/intl-de/artist/0SwO7SWeDHJijQ3XNS7xEE?si=17xfyfNGROyr18by1fh9sw

The new intl-de will make the regx expression not match anything.

Im not a regx pro but this seames to work:

^(http[s]?:\/\/)?open.spotify.com\/(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$

⬇️ (added .* after open.spotify.com\/)

^(http[s]?:\/\/)?open.spotify.com\/.*(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$
Originally created by @Commandcracker on GitHub (Jan 14, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1071 Originally assigned to: @dieser-niko on GitHub. https://github.com/spotipy-dev/spotipy/blob/a14a28e10c1889cce83eec7a7e1ad4b5944a452d/spotipy/client.py#L121C1-L121C173 The URL has some additions in some regions (for me Germany) `https://open.spotify.com/intl-de/track/2Y0iGXY6m6immVb2ktbseM?si=22cad793e8e248fe` `https://open.spotify.com/intl-de/artist/0SwO7SWeDHJijQ3XNS7xEE?si=17xfyfNGROyr18by1fh9sw` The new `intl-de` will make the regx expression not match anything. Im not a regx pro but this seames to work: ``` ^(http[s]?:\/\/)?open.spotify.com\/(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$ ``` ⬇️ (added `.*` after `open.spotify.com\/`) ``` ^(http[s]?:\/\/)?open.spotify.com\/.*(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$ ```
kerem closed this issue 2026-02-28 00:00:25 +03:00
Author
Owner

@dieser-niko commented on GitHub (May 3, 2024):

I think it would be better to add something more distinctive:

Added (intl-\w\w\/)? instead of .*:

^(http[s]?:\/\/)?open.spotify.com\/(intl-\w\w\/)?(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$

The intl-<countrycode> is still just optional, so this should work with the old format as well. I'll create a pull request sooner or later to implement this.

<!-- gh-comment-id:2092770796 --> @dieser-niko commented on GitHub (May 3, 2024): I think it would be better to add something more distinctive: Added `(intl-\w\w\/)?` instead of `.*`: ```regex ^(http[s]?:\/\/)?open.spotify.com\/(intl-\w\w\/)?(?P<type>track|artist|album|playlist|show|episode|user|audiobook)\/(?P<id>[0-9A-Za-z]+)(\?.*)?$ ``` The intl-\<countrycode> is still just optional, so this should work with the old format as well. I'll create a pull request sooner or later to implement this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#633
No description provided.