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:
@@ -50,7 +50,7 @@ func Parse(raw string) *ParsedURL {
|
||||
case isDeezerHost(host):
|
||||
return parseDeezer(raw, parts)
|
||||
case isSoundcloudHost(host):
|
||||
return parseSoundcloud(raw, parts)
|
||||
return parseSoundcloud(raw, host, parts)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@@ -85,6 +85,13 @@ func parseTidal(raw string, parts []string) *ParsedURL {
|
||||
return nil
|
||||
}
|
||||
|
||||
if isLangToken(parts[0]) {
|
||||
parts = parts[1:]
|
||||
}
|
||||
if len(parts) < 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if parts[0] == "browse" {
|
||||
parts = parts[1:]
|
||||
}
|
||||
@@ -128,14 +135,20 @@ func parseDeezer(raw string, parts []string) *ParsedURL {
|
||||
return &ParsedURL{OriginalURL: raw, Source: "deezer", MediaType: mediaType, ID: id, Kind: KindGeneric}
|
||||
}
|
||||
|
||||
func parseSoundcloud(raw string, parts []string) *ParsedURL {
|
||||
func parseSoundcloud(raw, host string, parts []string) *ParsedURL {
|
||||
if len(parts) < 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if host == "on.soundcloud.com" {
|
||||
return &ParsedURL{OriginalURL: raw, Source: "soundcloud", MediaType: "track", ID: raw, Kind: KindSoundcloud}
|
||||
}
|
||||
|
||||
mediaType := "track"
|
||||
if len(parts) >= 3 && parts[1] == "sets" {
|
||||
mediaType = "playlist"
|
||||
} else if len(parts) < 2 || parts[1] == "sets" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &ParsedURL{OriginalURL: raw, Source: "soundcloud", MediaType: mediaType, ID: raw, Kind: KindSoundcloud}
|
||||
@@ -169,7 +182,7 @@ func isTidalHost(host string) bool {
|
||||
}
|
||||
|
||||
func isDeezerHost(host string) bool {
|
||||
return host == "deezer.com"
|
||||
return host == "deezer.com" || strings.HasSuffix(host, ".deezer.com")
|
||||
}
|
||||
|
||||
func isSoundcloudHost(host string) bool {
|
||||
|
||||
Reference in New Issue
Block a user