Skip to content

Commit

Permalink
Tekstowo: update search URL to avoid redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Oct 9, 2024
1 parent d2303b7 commit adc2d20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/test_lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down

0 comments on commit adc2d20

Please sign in to comment.