From 822f0a8ec48b62d11e5ff734205e058f824b8f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Gauvin?= Date: Mon, 27 May 2024 00:56:07 +0200 Subject: [PATCH 1/2] Allow Spotify URL with country code --- zotify/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zotify/utils.py b/zotify/utils.py index dce9fd24..e86325e5 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -158,42 +158,42 @@ def regex_input_for_urls(search_input) -> Tuple[str, str, str, str, str, str]: track_uri_search = re.search( r'^spotify:track:(?P[0-9a-zA-Z]{22})$', search_input) track_url_search = re.search( - r'^(https?://)?open\.spotify\.com/track/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/track/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) album_uri_search = re.search( r'^spotify:album:(?P[0-9a-zA-Z]{22})$', search_input) album_url_search = re.search( - r'^(https?://)?open\.spotify\.com/album/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/album/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) playlist_uri_search = re.search( r'^spotify:playlist:(?P[0-9a-zA-Z]{22})$', search_input) playlist_url_search = re.search( - r'^(https?://)?open\.spotify\.com/playlist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/playlist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) episode_uri_search = re.search( r'^spotify:episode:(?P[0-9a-zA-Z]{22})$', search_input) episode_url_search = re.search( - r'^(https?://)?open\.spotify\.com/episode/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/episode/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) show_uri_search = re.search( r'^spotify:show:(?P[0-9a-zA-Z]{22})$', search_input) show_url_search = re.search( - r'^(https?://)?open\.spotify\.com/show/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/show/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) artist_uri_search = re.search( r'^spotify:artist:(?P[0-9a-zA-Z]{22})$', search_input) artist_url_search = re.search( - r'^(https?://)?open\.spotify\.com/artist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/artist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) From 2b080229a4d4af654f765ffe9b3159edfd697906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Gauvin?= Date: Mon, 27 May 2024 14:54:41 +0200 Subject: [PATCH 2/2] Allow Spotify URLs with country code --- zotify/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zotify/utils.py b/zotify/utils.py index e86325e5..cb98af61 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -165,35 +165,35 @@ def regex_input_for_urls(search_input) -> Tuple[str, str, str, str, str, str]: album_uri_search = re.search( r'^spotify:album:(?P[0-9a-zA-Z]{22})$', search_input) album_url_search = re.search( - r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/album/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/album/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) playlist_uri_search = re.search( r'^spotify:playlist:(?P[0-9a-zA-Z]{22})$', search_input) playlist_url_search = re.search( - r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/playlist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/playlist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) episode_uri_search = re.search( r'^spotify:episode:(?P[0-9a-zA-Z]{22})$', search_input) episode_url_search = re.search( - r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/episode/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/episode/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) show_uri_search = re.search( r'^spotify:show:(?P[0-9a-zA-Z]{22})$', search_input) show_url_search = re.search( - r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/show/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/show/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, ) artist_uri_search = re.search( r'^spotify:artist:(?P[0-9a-zA-Z]{22})$', search_input) artist_url_search = re.search( - r'^(https?://)?open\.spotify\.com(?:/intl-\w\w)?/artist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', + r'^(https?://)?open\.spotify\.com(?:/intl-\w+)?/artist/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$', search_input, )