diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index d83ea84cdc..0b07560444 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -243,7 +243,7 @@ def _encode(s): return urllib.parse.quote(s) def build_url(self, artist, title): - return self.URL_PATTERN % ( + return self.URL_PATTERN.format( self._encode(artist.title()), self._encode(title.title()), ) @@ -318,7 +318,7 @@ class MusiXmatch(Backend): r"[\]\}]": ")", } - URL_PATTERN = "https://www.musixmatch.com/lyrics/%s/%s" + URL_PATTERN = "https://www.musixmatch.com/lyrics/{}/{}" @classmethod def _encode(cls, s): @@ -520,8 +520,8 @@ def _try_extracting_lyrics_from_non_data_lyrics_container(self, soup): class Tekstowo(SearchBackend): # Fetch lyrics from Tekstowo.pl. - BASE_URL = "http://www.tekstowo.pl" - URL_PATTERN = BASE_URL + "/wyszukaj.html?search-title=%s&search-artist=%s" + BASE_URL = "https://www.tekstowo.pl" + URL_PATTERN = BASE_URL + "/szukaj,{}+{}.html" def fetch(self, artist, title, album=None, length=None): url = self.build_url(title, artist) diff --git a/docs/changelog.rst b/docs/changelog.rst index 97ca95c122..a7a19bc3b4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -87,6 +87,8 @@ Other changes: calculate the bpm. Previously this import was being done immediately, so every ``beet`` invocation was being delayed by a couple of seconds. :bug:`5185` +* :doc:`plugins/lyrics`: Update ``tekstowo`` backend search URL to use HTTPs + and to avoid redirects, which speeds up the response three times. 2.0.0 (May 30, 2024) -------------------- diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py index 79b4f6e268..2944027bbe 100644 --- a/test/plugins/test_lyrics.py +++ b/test/plugins/test_lyrics.py @@ -660,7 +660,7 @@ def test_multiple_results(self): mock = MockFetchUrl() assert ( tekstowo.parse_search_results(mock(url)) - == "http://www.tekstowo.pl/piosenka,juice_wrld," + == "https://www.tekstowo.pl/piosenka,juice_wrld," "lucid_dreams__remix__ft__lil_uzi_vert.html" )