Repository: 9dogs/tg-odesli-bot (language: python)

Issue:
New spotify link type
Found out that bot doesn't work with link

![image](https://user-images.githubusercontent.com/13254668/230776940-4f4e48a1-1522-4934-bab3-337303021fb5.png)

Firsly, I tried to check if [song.link](https://song.link/) works with that url type, but it didn't. So I emailed support about the problem and a couple of days ago they've fixed it. 

![image](https://user-images.githubusercontent.com/13254668/230778367-ced0884f-d79c-440b-a798-d5e4749a244e.png)

So now I'm going to fix Spotify regexp, since now it shows something strange for that link

![image](https://user-images.githubusercontent.com/13254668/230778308-49a08758-568c-4592-b01b-9775885d7f29.png)




Discussion / hints:

Fix patch:
diff --git a/tg_odesli_bot/platforms.py b/tg_odesli_bot/platforms.py
index dd055af..4c11768 100644
--- a/tg_odesli_bot/platforms.py
+++ b/tg_odesli_bot/platforms.py
@@ -72,7 +72,8 @@ class SpotifyPlatform(PlatformABC):
     key = 'spotify'
     url_re = (
         r'https?://([a-zA-Z\d-]+\.)*((spotify\.com/(album|track)/[^\s.,]*)'
-        r'|(tospotify\.com/[^\s.,]*))'
+        r'|(tospotify\.com/[^\s.,]*)'
+        r'|(spotify\.link/[^\s]*))'
     )
     name = 'Spotify'
     order = 3


Test patch:
diff --git a/tests/unit/test_bot.py b/tests/unit/test_bot.py
index 48ba0a0..ebbfe83 100644
--- a/tests/unit/test_bot.py
+++ b/tests/unit/test_bot.py
@@ -32,10 +32,11 @@ async def test_extracts_urls(self, bot: OdesliBot):
             '16 https://gunnarspardel.bandcamp.com/album/simplicity-in-a-'
             'complex-world\n'
             '17 https://carbonbasedlifeforms.bandcamp.com/track/6equj5\n'
-            '18 https://youtu.be/ugYB3VxpivU'
+            '18 https://youtu.be/ugYB3VxpivU\n'
+            '19 https://spotify.link/a9uvoB7YQyb'
         )
         urls = bot.extract_song_urls(text)
-        assert len(urls) == 18
+        assert len(urls) == 19
         deezer_url = urls[0]
         assert deezer_url.platform_key == 'deezer'
         assert deezer_url.url == 'https://www.deezer.com/track/568497412'
@@ -73,44 +74,47 @@ async def test_extracts_urls(self, bot: OdesliBot):
         spotify = urls[8]
         assert spotify.platform_key == 'spotify'
         assert spotify.url == 'https://link.tospotify.com/pfc3erwl2ab'
-        youtube_music = urls[9]
+        spotify = urls[9]
+        assert spotify.platform_key == 'spotify'
+        assert spotify.url == 'https://spotify.link/a9uvoB7YQyb'
+        youtube_music = urls[10]
         assert youtube_music.platform_key == 'youtubeMusic'
         assert youtube_music.url == (
             'https://music.youtube.com/watch?v=eVTXPUF4Oz4'
         )
-        youtube_music_album = urls[10]
+        youtube_music_album = urls[11]
         assert youtube_music_album.platform_key == 'youtubeMusic'
         assert youtube_music_album.url == (
             'https://music.youtube.com/playlist?list='
             'OLAK5uy_l2F5ezYgFM0mQ3tg2-vK900BTgr8zXMW0'
         )
-        youtube = urls[11]
+        youtube = urls[12]
         assert youtube.platform_key == 'youtube'
         assert youtube.url == 'https://www.youtube.com/watch?v=eVTXPUF4Oz4'
-        youtube_album = urls[12]
+        youtube_album = urls[13]
         assert youtube_album.platform_key == 'youtube'
         assert youtube_album.url == (
             'https://www.youtube.com/playlist?list='
             'OLAK5uy_n64ojqXEYWqrvO5GAWU1Ik040wTIzBdbQ'
         )
-        youtube_short = urls[13]
+        youtube_short = urls[14]
         assert youtube_short.platform_key == 'youtube'
         assert youtube_short.url == 'https://youtu.be/ugYB3VxpivU'
-        apple_music = urls[14]
+        apple_music = urls[15]
         assert apple_music.platform_key == 'appleMusic'
         assert apple_music.url == (
             'https://music.apple.com/se/album/raindrops-feat-j3po/1450701158'
         )
-        tidal = urls[15]
+        tidal = urls[16]
         assert tidal.platform_key == 'tidal'
         assert tidal.url == 'https://tidal.com/track/139494756'
-        bandcamp_album = urls[16]
+        bandcamp_album = urls[17]
         assert bandcamp_album.platform_key == 'bandcamp'
         assert bandcamp_album.url == (
             'https://gunnarspardel.bandcamp.com/album/simplicity-in-a-'
             'complex-world'
         )
-        bandcamp_track = urls[17]
+        bandcamp_track = urls[18]
         assert bandcamp_track.platform_key == 'bandcamp'
         assert bandcamp_track.url == (
             'https://carbonbasedlifeforms.bandcamp.com/track/6equj5'