Debian Codegraph @

test/plugins/lyrics_pages.py

raw
1 from __future__ import annotations
2
3 import os
4 import textwrap
5 from typing import NamedTuple
6 from urllib.parse import urlparse
7
8 import pytest
9
10
11 def xfail_on_ci(msg: str) -> pytest.MarkDecorator:
12 return pytest.mark.xfail(
13 bool(os.environ.get("GITHUB_ACTIONS")),
14 reason=msg,
15 raises=AssertionError,
16 )
17
18
19 class LyricsPage(NamedTuple):
20 """Lyrics page representation for integrated tests."""
21
22 url: str
23 lyrics: str
24 artist: str = "The Beatles"
25 track_title: str = "Lady Madonna"
26 language: str = "EN"
27 url_title: str | None = None # only relevant to the Google backend
28 marks: list[str] = [] # markers for pytest.param # noqa: RUF012
29
30 def __str__(self) -> str:
31 """Return name of this test case."""
32 return f"{self.backend}-{self.source}"
33
34 @classmethod
35 def make(cls, url, lyrics, *args, **kwargs):
36 return cls(url, textwrap.dedent(lyrics).strip(), *args, **kwargs)
37
38 @property
39 def root_url(self) -> str:
40 return urlparse(self.url).netloc
41
42 @property
43 def source(self) -> str:
44 return (
45 self.root_url.replace("www.", "").replace("api.", "").split(".")[0]
46 )
47
48 @property
49 def backend(self) -> str:
50 if (source := self.source) in {
51 "genius",
52 "tekstowo",
53 "lrclib",
54 "lrcmux",
55 }:
56 return source
57 return "google"
58
59
60 lyrics_pages = [
61 LyricsPage.make(
62 "http://www.absolutelyrics.com/lyrics/view/the_beatles/lady_madonna",
63 """
64 The Beatles - Lady Madonna
65
66 Lady Madonna, children at your feet.
67 Wonder how you manage to make ends meet.
68 Who finds the money? When you pay the rent?
69 Did you think that money was heaven sent?
70 Friday night arrives without a suitcase.
71 Sunday morning creep in like a nun.
72 Monday's child has learned to tie his bootlace.
73 See how they run.
74 Lady Madonna, baby at your breast.
75 Wonder how you manage to feed the rest.
76 See how they run.
77 Lady Madonna, lying on the bed,
78 Listen to the music playing in your head.
79 Tuesday afternoon is never ending.
80 Wednesday morning papers didn't come.
81 Thursday night you stockings needed mending.
82 See how they run.
83 Lady Madonna, children at your feet.
84 Wonder how you manage to make ends meet.
85 """,
86 url_title="Lady Madonna Lyrics :: The Beatles - Absolute Lyrics",
87 ),
88 LyricsPage.make(
89 "https://www.azlyrics.com/lyrics/beatles/ladymadonna.html",
90 """
91 Lady Madonna, children at your feet
92 Wonder how you manage to make ends meet
93 Who finds the money when you pay the rent
94 Did you think that money was Heaven sent?
95 Friday night arrives without a suitcase
96 Sunday morning creeping like a nun
97 Monday's child has learned to tie his bootlace
98 See how they run
99
100 Lady Madonna, baby at your breast
101 Wonders how you manage to feed the rest?
102
103 See how they run
104
105 Lady Madonna lying on the bed
106 Listen to the music playing in your head
107
108 Tuesday afternoon is never ending
109 Wednesday morning papers didn't come
110 Thursday night your stockings needed mending
111 See how they run
112
113 Lady Madonna, children at your feet
114 Wonder how you manage to make ends meet
115 """,
116 url_title="The Beatles - Lady Madonna Lyrics | AZLyrics.com",
117 marks=[xfail_on_ci("AZLyrics is blocked by Cloudflare")],
118 ),
119 LyricsPage.make(
120 "https://www.dainuzodziai.lt/m/mergaites-nori-mylet-atlanta/",
121 """
122 Jos nesuspėja skriet paskui vėją
123 Bangos į krantą grąžina jas vėl
124 Jos karštą saulę paliesti norėjo
125 Ant kranto palikę visas negandas
126
127 Bet jos nori mylėt
128 Jos nenori liūdėt
129 Leisk mergaitėms mylėt
130 Kaip jos moka mylėt
131 Koks vakaras šiltas ir nieko nestinga
132 Veidus apšviečia žaisminga šviesa
133 Jos buvo laimingos prie jūros kur liko
134 Tik vėjas išmokęs visas jų dainas
135 """,
136 artist="Atlanta",
137 track_title="Mergaitės Nori Mylėt",
138 language="LT",
139 url_title="Mergaitės nori mylėt – Atlanta | Dainų Žodžiai",
140 marks=[xfail_on_ci("Expired SSL certificate")],
141 ),
142 LyricsPage.make(
143 "https://genius.com/The-beatles-lady-madonna-lyrics",
144 """
145 [Verse 1: Paul McCartney]
146 Lady Madonna, children at your feet
147 Wonder how you manage to make ends meet
148 Who finds the money when you pay the rent?
149 Did you think that money was heaven sent?
150
151 [Bridge: Paul McCartney, Paul McCartney, John Lennon & George Harrison]
152 Friday night arrives without a suitcase
153 Sunday morning creeping like a nun
154 Monday's child has learned to tie his bootlace
155 See how they run
156
157 [Verse 2: Paul McCartney]
158 Lady Madonna, baby at your breast
159 Wonders how you manage to feed the rest
160 [Tenor Saxophone Solo: Ronnie Scott]
161
162 [Bridge: John Lennon & George Harrison, Paul McCartney, John Lennon & George Harrison]
163 Pa-pa-pa-pa, pa-pa-pa-pa-pa
164 Pa-pa-pa-pa-pa, pa-pa-pa, pa-pa, pa-pa
165 Pa-pa-pa-pa, pa-pa-pa-pa-pa
166 See how they run
167
168 [Verse 3: Paul McCartney]
169 Lady Madonna, lying on the bed
170 Listen to the music playing in your head
171
172 [Bridge: Paul McCartney, John Lennon & George Harrison, Paul McCartney, John Lennon & George Harrison]
173 Tuesday afternoon is never ending (Pa-pa-pa-pa, pa-pa-pa-pa-pa)
174 Wednesday morning, papers didn't come (Pa-pa-pa-pa-pa, pa-pa-pa, pa-pa, pa-pa)
175 Thursday night, your stockings needed mending (Pa-pa-pa-pa, pa-pa-pa-pa-pa)
176 See how they run
177
178 [Verse 4: Paul McCartney]
179 Lady Madonna, children at your feet
180 Wonder how you manage to make ends meet
181 """, # noqa: E501
182 marks=[xfail_on_ci("Genius returns 403 FORBIDDEN in CI")],
183 ),
184 LyricsPage.make(
185 "https://www.lacoccinelle.net/259956-the-beatles-lady-madonna.html",
186 """
187 Lady Madonna
188 Mademoiselle Madonna
189
190 Lady Madonna, children at your feet.
191 Mademoiselle Madonna, les enfants à vos pieds
192 Wonder how you manage to make ends meet.
193 Je me demande comment vous vous débrouillez pour joindre les deux bouts
194 Who finds the money, when you pay the rent ?
195 Qui trouve l'argent pour payer le loyer ?
196 Did you think that money was heaven sent ?
197 Pensiez-vous que ça allait être envoyé du ciel ?
198
199 Friday night arrives without a suitcase.
200 Le vendredi soir arrive sans bagages
201 Sunday morning creeping like a nun.
202 Le dimanche matin elle se traine comme une nonne
203 Monday's child has learned to tie his bootlace.
204 Lundi l'enfant a appris à lacer ses chaussures
205 See how they run.
206 Regardez comme ils courent
207
208 Lady Madonna, baby at your breast.
209 Mademoiselle Madonna, le bébé a votre sein
210 Wonder how you manage to feed the rest.
211 Je me demande comment vous faites pour nourrir le reste
212
213 Lady Madonna, lying on the bed,
214 Mademoiselle Madonna, couchée sur votre lit
215 Listen to the music playing in your head.
216 Vous écoutez la musique qui joue dans votre tête
217
218 Tuesday afternoon is never ending.
219 Le mardi après-midi n'en finit pas
220 Wednesday morning papers didn't come.
221 Le mercredi matin les journaux ne sont pas arrivés
222 Thursday night you stockings needed mending.
223 Jeudi soir, vos bas avaient besoin d'être réparés
224 See how they run.
225 Regardez comme ils filent
226
227 Lady Madonna, children at your feet.
228 Mademoiselle Madonna, les enfants à vos pieds
229 Wonder how you manage to make ends meet.
230 Je me demande comment vous vous débrouillez pour joindre les deux bouts
231 """,
232 url_title="Paroles et traduction The Beatles : Lady Madonna - paroles de chanson", # noqa: E501
233 language="FR",
234 ),
235 LyricsPage.make(
236 # note that this URL needs to be followed with a slash, otherwise it
237 # redirects to the same URL with a slash
238 "https://www.letras.mus.br/the-beatles/275/",
239 """
240 Lady Madonna
241 Children at your feet
242 Wonder how you manage
243 To make ends meet
244
245 Who finds the money
246 When you pay the rent?
247 Did you think that money
248 Was Heaven sent?
249
250 Friday night arrives without a suitcase
251 Sunday morning creeping like a nun
252 Monday's child has learned
253 To tie his bootlace
254 See how they run
255
256 Lady Madonna
257 Baby at your breast
258 Wonders how you manage
259 To feed the rest
260 See how they run
261
262 Lady Madonna
263 Lying on the bed
264 Listen to the music
265 Playing in your head
266
267 Tuesday afternoon is neverending
268 Wednesday morning papers didn't come
269 Thursday night your stockings
270 Needed mending
271 See how they run
272
273 Lady Madonna
274 Children at your feet
275 Wonder how you manage
276 To make ends meet
277 """,
278 url_title="Lady Madonna - The Beatles - LETRAS.MUS.BR",
279 ),
280 LyricsPage.make(
281 "https://lrclib.net/api/get/23863037",
282 """
283 [00:08.35] Lady Madonna, children at your feet
284 [00:12.85] Wonder how you manage to make ends meet
285 [00:17.56] Who finds the money when you pay the rent
286 [00:21.78] Did you think that money was heaven sent
287 [00:26.22] Friday night arrives without a suitcase
288 [00:30.02] Sunday morning creeping like a nun
289 [00:34.53] Monday's child has learned to tie his bootlace
290 [00:39.18] See how they run
291 [00:43.33] Lady Madonna, baby at your breast
292 [00:48.50] Wonders how you manage to feed the rest
293 [00:52.54]
294 [01:01.32] Ba-ba, ba-ba, ba-ba, ba-ba-ba
295 [01:05.03] Ba-ba, ba-ba, ba-ba, ba, ba-ba, ba-ba
296 [01:09.58] Ba-ba, ba-ba, ba-ba, ba-ba-ba
297 [01:14.27] See how they run
298 [01:19.05] Lady Madonna, lying on the bed
299 [01:22.99] Listen to the music playing in your head
300 [01:27.92]
301 [01:36.33] Tuesday afternoon is never ending
302 [01:40.47] Wednesday morning papers didn't come
303 [01:44.76] Thursday night your stockings needed mending
304 [01:49.35] See how they run
305 [01:53.73] Lady Madonna, children at your feet
306 [01:58.65] Wonder how you manage to make ends meet
307 [02:06.04]
308 """,
309 ),
310 LyricsPage.make(
311 "https://api.lrcmux.dev/get?artist=The+Beatles&title=Lady+Madonna&duration=186&format=lrc&level=line&sources=ytmusic",
312 """
313 [00:00.00]
314 [00:08.71] Lady Madonna, children at your feet
315 [00:13.08] Wonder how you manage to make ends meet
316 [00:17.43] Who finds the money when you pay the rent?
317 [00:21.92] Did you think that money was Heaven-sent?
318 [00:26.21] Friday night arrives without a suitcase
319 [00:30.54] Sunday morning creeping like a nun
320 [00:35.07] Monday's child has learned to tie his bootlace
321 [00:39.37] See how they run
322 [00:43.80] Lady Madonna, baby at your breast
323 [00:48.23] Wonders how you manage to feed the rest
324 [00:55.32]
325 [01:01.30] Pa-pa-pa-pa, pa-pa-pa-pa-pa
326 [01:05.68] Pa-pa-pa-pa, pa-pa-pa-pa-pa-pa-pa
327 [01:09.86] Pa-pa-pa-pa, pa-pa-pa-pa-pa
328 [01:14.40] See how they run
329 [01:18.81] Lady Madonna lying on the bed
330 [01:23.25] Listen to the music playing in your head
331 [01:30.21]
332 [01:36.40] Tuesday afternoon is never ending
333 [01:40.78] Wednesday morning papers didn't come
334 [01:45.06] Thursday night you stocking needed mending
335 [01:49.48] See how they run
336 [01:53.90] Lady Madonna, children at your feet
337 [01:58.42] Wonder how you manage to make ends meet
338 """,
339 ),
340 LyricsPage.make(
341 "https://www.lyricsmania.com/lady_madonna_lyrics_the_beatles.html",
342 """
343 Lady Madonna, children at your feet.
344 Wonder how you manage to make ends meet.
345 Who finds the money? When you pay the rent?
346 Did you think that money was heaven sent?
347
348 Friday night arrives without a suitcase.
349 Sunday morning creep in like a nun.
350 Monday's child has learned to tie his bootlace.
351 See how they run.
352
353 Lady Madonna, baby at your breast.
354 Wonder how you manage to feed the rest.
355
356 See how they run.
357 Lady Madonna, lying on the bed,
358 Listen to the music playing in your head.
359
360 Tuesday afternoon is never ending.
361 Wednesday morning papers didn't come.
362 Thursday night you stockings needed mending.
363 See how they run.
364
365 Lady Madonna, children at your feet.
366 Wonder how you manage to make ends meet.
367 """,
368 url_title="The Beatles - Lady Madonna Lyrics",
369 ),
370 LyricsPage.make(
371 "https://www.lyricsmode.com/lyrics/b/beatles/mother_natures_son.html",
372 """
373 Born a poor young country boy, Mother Nature's son
374 All day long I'm sitting singing songs for everyone
375
376 Sit beside a mountain stream, see her waters rise
377 Listen to the pretty sound of music as she flies
378
379 Doo doo doo doo doo doo doo doo doo doo doo
380 Doo doo doo doo doo doo doo doo doo
381 Doo doo doo
382
383 Find me in my field of grass, Mother Nature's son
384 Swaying daises sing a lazy song beneath the sun
385
386 Doo doo doo doo doo doo doo doo doo doo doo
387 Doo doo doo doo doo doo doo doo doo
388 Doo doo doo doo doo doo
389 Yeah yeah yeah
390
391 Mm mm mm mm mm mm mm
392 Mm mm mm, ooh ooh ooh
393 Mm mm mm mm mm mm mm
394 Mm mm mm mm, wah wah wah
395
396 Wah, Mother Nature's son
397 """,
398 artist="The Beatles",
399 track_title="Mother Nature's Son",
400 url_title=(
401 "Mother Nature's Son lyrics by The Beatles - original song full"
402 " text. Official Mother Nature's Son lyrics, 2025 version"
403 " | LyricsMode.com"
404 ),
405 ),
406 LyricsPage.make(
407 "https://www.lyricsontop.com/amy-winehouse-songs/jazz-n-blues-lyrics.html",
408 """
409 It's all gone within two days,
410 Follow my father
411 His extravagant ways
412 So, if I got it out I'll spend it all.
413 Heading In parkway, til I hit the wall.
414 I cross my fingers at the cash machine,
415 As I check my balance I kiss the screen,
416 I love it when it says I got the main's
417 To got o Miss Sixty and pick up my jeans.
418 Money ever last long
419 Had to fight what's wrong,
420 Blow it all on bags and shoes,
421 Jazz n' blues.
422 Money ever last long,
423 Had to fight what's wrong,
424 Blow it all on bags and shoes,
425 Jazz n' blues.
426
427 Standing to the … bar today,
428 Waiting impatient to throw my cash away,
429 For that Russian JD and coke
430 Had the drinks all night, and now I am bold
431 But that's cool, cause I can buy more from you.
432 And I didn't forgot about that 50 Compton,
433 Tell you what? My fancy's coming through
434 I'll take you at shopping, can you wait til next June?
435 Yeah, Money ever last long
436 Had to fight what's wrong,
437 Blow it all on bags and shoes,
438 Jazz n' blues.
439 Money ever last long,
440 Had to fight what's wrong,
441 Blow it all on bags and shoes,
442 Jazz n' blues.
443
444 (Instrumental Break)
445
446 Money ever last long
447 Had to fight what's wrong,
448 Blow it all on bags and shoes,
449 Jazz n' blues.
450 Money ever last long,
451 Had to fight what's wrong,
452 Blow it all on bags and shoes,
453 Jazz n' blues.
454 Money ever last long,
455 Had to fight what's wrong,
456 Blow it all on bags and shoes,
457 Jazz n' blues.
458 """,
459 artist="Amy Winehouse",
460 track_title="Jazz N' Blues",
461 url_title="Amy Winehouse - Jazz N' Blues lyrics complete",
462 ),
463 LyricsPage.make(
464 "https://www.musica.com/letras.asp?letra=59862",
465 """
466 Lady Madonna, children at your feet
467 Wonder how you manage to make ends meet
468 Who finds the money when you pay the rent?
469 Did you think that money was heaven sent?
470
471 Friday night arrives without a suitcase
472 Sunday morning creeping like a nun
473 Monday's child has learned to tie his bootlace
474 See how they run
475
476 Lady Madonna, baby at your breast
477 Wonders how you manage to feed the rest
478
479 See how they run
480
481 Lady Madonna lying on the bed
482 Listen to the music playing in your head
483
484 Tuesday afternoon is never ending
485 Wednesday morning papers didn't come
486 Thursday night your stockings needed mending
487 See how they run
488
489 Lady Madonna, children at your feet
490 Wonder how you manage to make ends meet
491 """,
492 url_title="Lady Madonna - Letra - The Beatles - Musica.com",
493 ),
494 LyricsPage.make(
495 "https://www.paroles.net/the-beatles/paroles-lady-madonna",
496 """
497 Lady Madonna, children at your feet.
498 Wonder how you manage to make ends meet.
499 Who finds the money? When you pay the rent?
500 Did you think that money was heaven sent?
501
502 Friday night arrives without a suitcase.
503 Sunday morning creep in like a nun.
504 Monday's child has learned to tie his bootlace.
505 See how they run.
506
507 Lady Madonna, baby at your breast.
508 Wonders how you manage to feed the rest.
509
510 See how they run.
511 Lady Madonna, lying on the bed,
512 Listen to the music playing in your head.
513
514 Tuesday afternoon is never ending.
515 Wednesday morning papers didn't come.
516 Thursday night your stockings needed mending.
517 See how they run.
518
519 Lady Madonna, children at your feet.
520 Wonder how you manage to make ends meet.
521 """,
522 url_title="Paroles Lady Madonna par The Beatles - Lyrics - Paroles.net",
523 ),
524 LyricsPage.make(
525 "https://www.songlyrics.com/the-beatles/lady-madonna-lyrics",
526 """
527 Lady Madonna, children at your feet
528 Wonder how you manage to make ends meet
529 Who finds the money? When you pay the rent?
530 Did you think that money was Heaven sent?
531 Friday night arrives without a suitcase
532 Sunday morning creep in like a nun
533 Monday's child has learned to tie his bootlace
534 See how they run
535
536 Lady Madonna, baby at your breast
537 Wonder how you manage to feed the rest
538
539 See how they run
540
541 Lady Madonna, lying on the bed
542 Listen to the music playing in your head
543
544 Tuesday afternoon is never ending
545 Wednesday morning papers didn't come
546 Thursday night you stockings needed mending
547 See how they run
548
549 Lady Madonna, children at your feet
550 Wonder how you manage to make ends meet
551 """,
552 url_title="THE BEATLES - LADY MADONNA LYRICS",
553 marks=[xfail_on_ci("Songlyrics is blocked by Cloudflare")],
554 ),
555 LyricsPage.make(
556 "https://sweetslyrics.com/the-beatles/lady-madonna-lyrics",
557 """
558 Lady Madonna, children at your feet.
559 Wonder how you manage to make ends meet.
560 Who finds the money when you pay the rent?
561 Did you think that money was heaven sent?
562
563 Friday night arrives without a suitcase.
564 Sunday morning creeping like a nun.
565 Monday's child has learned to tie his bootlace.
566 See how they run...
567
568 Lady Madonna, baby at your breast.
569 Wonders how you manage to feed the rest.
570
571 (Sax solo)
572
573 See how they run...
574
575 Lady Madonna, lying on the bed.
576 Listen to the music playing in your head.
577
578 Tuesday afternoon is never ending.
579 Wednesday morning papers didn't come.
580 Thursday night your stockings needed mending.
581 See how they run...
582
583 Lady Madonna, children at your feet.
584 Wonder how you manage to make ends meet.
585 """,
586 url_title="The Beatles - Lady Madonna",
587 marks=[xfail_on_ci("Sweetslyrics also fails with 403 FORBIDDEN in CI")],
588 ),
589 LyricsPage.make(
590 "https://www.tekstowo.pl/piosenka,the_beatles,lady_madonna.html",
591 """
592 Lady Madonna,
593 Children at your feet
594 Wonder how you manage to make ends meet.
595
596 Who find the money
597 When you pay the rent?
598 Did you think that money was Heaven sent?
599
600 Friday night arrives without a suitcase
601 Sunday morning creeping like a nun
602 Monday's child has learned to tie his bootlace
603
604 See how they run
605
606 Lady Madonna
607 Baby at your breast
608 Wonders how you manage to feed the rest
609
610 See how they run
611
612 Lady Madonna
613 Lying on the bed
614 Listen to the music playing in your head
615
616 Tuesday afternoon is neverending
617 Wednesday morning papers didn't come
618 Thursday night your stockings needed mending
619
620 See how they run
621
622 Lady Madonna,
623 Children at your feet
624 Wonder how you manage to make ends meet
625 """,
626 marks=[pytest.mark.xfail(reason="Tekstowo seems to be broken again")],
627 ),
628 ]