mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
tighten lastfm parsing and locale url handling
This commit is contained in:
@@ -28,13 +28,19 @@ func TestQobuzAlbumURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTidalTrackURL(t *testing.T) {
|
||||
url := "https://tidal.com/browse/track/3083287"
|
||||
result := Parse(url)
|
||||
if result == nil {
|
||||
t.Fatalf("expected parsed url")
|
||||
inputs := []string{
|
||||
"https://tidal.com/browse/track/3083287",
|
||||
"https://tidal.com/us/browse/track/3083287",
|
||||
"https://tidal.com/us/track/3083287",
|
||||
}
|
||||
if result.Source != "tidal" || result.MediaType != "track" || result.ID != "3083287" {
|
||||
t.Fatalf("unexpected parse result: %+v", result)
|
||||
for _, url := range inputs {
|
||||
result := Parse(url)
|
||||
if result == nil {
|
||||
t.Fatalf("expected parsed url for %q", url)
|
||||
}
|
||||
if result.Source != "tidal" || result.MediaType != "track" || result.ID != "3083287" {
|
||||
t.Fatalf("unexpected parse result for %q: %+v", url, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +99,7 @@ func TestURLWithLanguageCode(t *testing.T) {
|
||||
"https://www.qobuz.com/gb-en/album/name/id123456",
|
||||
"https://www.deezer.com/en/track/4195713",
|
||||
"https://www.deezer.com/fr/track/4195713",
|
||||
"https://m.deezer.com/en/track/4195713",
|
||||
}
|
||||
for _, input := range inputs {
|
||||
if result := Parse(input); result == nil {
|
||||
@@ -101,6 +108,17 @@ func TestURLWithLanguageCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeezerMobileHostURL(t *testing.T) {
|
||||
url := "https://m.deezer.com/track/4195713"
|
||||
result := Parse(url)
|
||||
if result == nil {
|
||||
t.Fatalf("expected parsed url")
|
||||
}
|
||||
if result.Source != "deezer" || result.MediaType != "track" || result.ID != "4195713" {
|
||||
t.Fatalf("unexpected parse result: %+v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSoundcloudURL(t *testing.T) {
|
||||
inputs := []string{
|
||||
"https://soundcloud.com/artist-name/track-name",
|
||||
@@ -118,3 +136,15 @@ func TestSoundcloudURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSoundcloudProfileURLIsNotTrack(t *testing.T) {
|
||||
if result := Parse("https://soundcloud.com/artist-name"); result != nil {
|
||||
t.Fatalf("expected nil for profile url, got %+v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSoundcloudSetsRootWithoutPlaylistSlugInvalid(t *testing.T) {
|
||||
if result := Parse("https://soundcloud.com/artist-name/sets"); result != nil {
|
||||
t.Fatalf("expected nil for sets root url, got %+v", result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user