From bb158ff4c1d21daf27377d6439ee441be3540d0f Mon Sep 17 00:00:00 2001 From: ivan g Date: Sat, 15 Nov 2025 21:42:04 -0600 Subject: [PATCH] fix tidal /u suffix in url messes with the regex fixes gh-910 --- streamrip/rip/parse_url.py | 4 ++++ tests/test_parse_url.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/streamrip/rip/parse_url.py b/streamrip/rip/parse_url.py index bdfa0b03..8567132f 100644 --- a/streamrip/rip/parse_url.py +++ b/streamrip/rip/parse_url.py @@ -54,6 +54,10 @@ async def into_pending( class GenericURL(URL): @classmethod def from_str(cls, url: str) -> URL | None: + # tidal.com/track/123/u messes with the regex + if "tidal.com" in url and url.endswith("/u"): + url = url.rstrip("/u") + generic_url = URL_REGEX.match(url) if generic_url is None: return None diff --git a/tests/test_parse_url.py b/tests/test_parse_url.py index 9048cd64..ba44bbd3 100644 --- a/tests/test_parse_url.py +++ b/tests/test_parse_url.py @@ -51,6 +51,18 @@ def test_tidal_track_url(self): self.assertEqual(groups[1], "track") # media_type self.assertEqual(groups[2], "3083287") # item_id + _test = lambda u: parse_url(u).match.groups() + + self.assertEqual( + _test("https://tidal.com/track/144921990/u"), + ("tidal", "track", "144921990"), + ) + + self.assertEqual( + _test("https://tidal.com/track/454879903?u"), + ("tidal", "track", "454879903"), + ) + def test_deezer_track_url(self): """Test that Deezer track URLs are matched correctly.""" url = "https://www.deezer.com/track/4195713"