Skip to content

Commit

Permalink
Google: add support for dainuzodziai.lt
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Oct 26, 2024
1 parent 7908e96 commit cb559f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ class Html:
#: (paroles.net, sweetslyrics.com, lacoccinelle.net)
merge_lines = partial(re.compile(r"</p>\s+<p[^>]*>(?!___)").sub, "\n")
#: remove empty divs (lacoccinelle.net)
remove_empty_divs = partial(re.compile(r"<div[^>]*>\s*</div>").sub, "")
remove_empty_tags = partial(
re.compile(r"(<(div|span)[^>]*>\s*</\2>)").sub, ""
)
#: remove Google Ads tags (musica.com)
remove_aside = partial(re.compile("<aside .+?</aside>").sub, "")
#: remove adslot-Content_1 div from the lyrics text (paroles.net)
Expand All @@ -469,7 +471,7 @@ def remove_ads(cls, text: str) -> str:

@classmethod
def merge_paragraphs(cls, text: str) -> str:
return cls.merge_blocks(cls.merge_lines(cls.remove_empty_divs(text)))
return cls.merge_blocks(cls.merge_lines(cls.remove_empty_tags(text)))


class SoupMixin:
Expand Down Expand Up @@ -641,6 +643,7 @@ class Google(SearchBackend):
paroles(\ et\ traduction|\ de\ chanson)?
| letras?(\ de)?
| liedtexte
| dainų\ žodžiai
| original\ song\ full\ text\.
| official
| 20[12]\d\ version
Expand Down
21 changes: 21 additions & 0 deletions test/plugins/lyrics_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ def backend(self) -> str:
""",
url_title="The Beatles Lady Madonna lyrics",
),
LyricsPage.make(
"https://www.dainuzodziai.lt/m/mergaites-nori-mylet-atlanta/",
"""
Jos nesuspėja skriet paskui vėją
Bangos į krantą grąžina jas vėl
Jos karštą saulę paliesti norėjo
Ant kranto palikę visas negandas
Bet jos nori mylėt
Jos nenori liūdėt
Leisk mergaitėms mylėt
Kaip jos moka mylėt
Koks vakaras šiltas ir nieko nestinga
Veidus apšviečia žaisminga šviesa
Jos buvo laimingos prie jūros kur liko
Tik vėjas išmokęs visas jų dainas
""",
artist="Atlanta",
track_title="Mergaitės Nori Mylėt",
url_title="Mergaitės nori mylėt – Atlanta | Dainų Žodžiai",
),
LyricsPage.make(
"https://genius.com/The-beatles-lady-madonna-lyrics",
"""
Expand Down

0 comments on commit cb559f0

Please sign in to comment.