mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
fix lastfm extraction regression and honor no-db
This commit is contained in:
@@ -171,6 +171,25 @@ func TestExtractLastFMTitleArtistPairsSingleQuotes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractLastFMTitleArtistPairsSkipsPlayOnYouTubeNoise(t *testing.T) {
|
||||
html := `<a href="https://www.youtube.com/watch?v=1" data-track-name="Won't Forget You" data-artist-name="Shouse" title="Play on YouTube">Play track</a>
|
||||
<a href="/music/Shouse/_/Won%27t+Forget+You" title="Won't Forget You"></a>
|
||||
<a href="/music/Shouse" title="Shouse"></a>
|
||||
<a href="https://www.youtube.com/watch?v=2" data-track-name="EYES" data-artist-name="The Blaze" title="Play on YouTube">Play track</a>
|
||||
<a href="/music/The+Blaze/_/EYES" title="EYES"></a>
|
||||
<a href="/music/The+Blaze" title="The Blaze"></a>`
|
||||
pairs := extractLastFMTitleArtistPairs(html)
|
||||
if len(pairs) != 2 {
|
||||
t.Fatalf("pairs len = %d, want 2", len(pairs))
|
||||
}
|
||||
if pairs[0].Title != "Won't Forget You" || pairs[0].Artist != "Shouse" {
|
||||
t.Fatalf("unexpected first pair: %+v", pairs[0])
|
||||
}
|
||||
if pairs[1].Title != "EYES" || pairs[1].Artist != "The Blaze" {
|
||||
t.Fatalf("unexpected second pair: %+v", pairs[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGlobalArgsNoDBBeforeCommand(t *testing.T) {
|
||||
opts, err := parseGlobalArgs([]string{"-ndb", "url", "https://play.qobuz.com/album/0004228000522"})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user