From 1c8cd6ed3239836870bedc3271fbc44b0e2cb3a7 Mon Sep 17 00:00:00 2001 From: ngn Date: Wed, 9 Apr 2025 19:26:23 +0300 Subject: [PATCH] remove lyrics header patch from upstream repo https://github.com/rramiachraf/dumb/pull/90 Signed-off-by: ngn --- data/lyrics.go | 2 ++ handlers/lyrics_test.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/data/lyrics.go b/data/lyrics.go index bb1dc39..3b67541 100644 --- a/data/lyrics.go +++ b/data/lyrics.go @@ -58,6 +58,8 @@ type customPerformance struct { func (s *Song) parseLyrics(doc *goquery.Document) error { var htmlError error + doc.Find("[class^=LyricsHeader]").Remove() + doc.Find("[data-lyrics-container='true']").Each(func(i int, ss *goquery.Selection) { h, err := ss.Html() if err != nil { diff --git a/handlers/lyrics_test.go b/handlers/lyrics_test.go index 56db727..4501166 100644 --- a/handlers/lyrics_test.go +++ b/handlers/lyrics_test.go @@ -4,6 +4,7 @@ import ( "net/http" "net/http/httptest" "os" + "strings" "testing" "github.com/PuerkitoBio/goquery" @@ -25,6 +26,7 @@ func TestLyrics(t *testing.T) { func testLyrics(t *testing.T, url string) { title := "The Silver Seas" artist := "Catch Yer Own Train" + firstLyricLine := "[Verse 1]" r, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { @@ -46,6 +48,7 @@ func testLyrics(t *testing.T, url string) { docArtist := doc.Find("#metadata-info h1").Text() docTitle := doc.Find("#metadata-info h2").Text() + docLyrics := doc.Find("#lyrics").Text() if docTitle != title { t.Fatalf("expected %q, got %q\n", title, docTitle) @@ -54,4 +57,8 @@ func testLyrics(t *testing.T, url string) { if docArtist != artist { t.Fatalf("expected %q, got %q\n", artist, docArtist) } + + if !strings.HasPrefix(docLyrics, firstLyricLine) { + t.Fatalf("expected lyrics to start with %q, got %q\n", firstLyricLine, docLyrics) + } }