mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-07-27 23:42:28 +02:00
feat: add beatport provider
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ func addURLToQueue(ctx context.Context, mainApp *app.Main, raw string) bool {
|
||||
fmt.Printf("not yet supported: %s (kind=%s)\n", raw, parsed.Kind)
|
||||
return false
|
||||
}
|
||||
if parsed.Source != "qobuz" && parsed.Source != "tidal" && parsed.Source != "deezer" && parsed.Source != "yandex" && parsed.Source != "soundcloud" {
|
||||
if parsed.Source != "qobuz" && parsed.Source != "tidal" && parsed.Source != "deezer" && parsed.Source != "yandex" && parsed.Source != "beatport" && parsed.Source != "soundcloud" {
|
||||
fmt.Printf("provider not yet implemented: source=%s url=%s\n", parsed.Source, raw)
|
||||
return false
|
||||
}
|
||||
|
||||
+12
-2
@@ -294,7 +294,7 @@ func main() {
|
||||
}
|
||||
case "id":
|
||||
if len(os.Args) < 5 {
|
||||
fmt.Println("usage: rip id <source> <track|album|playlist|artist|label|video> <id> [quality] [--force|--ignore-db]")
|
||||
fmt.Println("usage: rip id <source> <track|album|playlist|artist|label|chart|video> <id> [quality] [--force|--ignore-db]")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -319,6 +319,12 @@ func main() {
|
||||
cfg.Session.Tidal.Quality = opts.quality
|
||||
case "yandex":
|
||||
cfg.Session.Yandex.Quality = opts.quality
|
||||
case "beatport":
|
||||
if opts.quality < 1 {
|
||||
fmt.Fprintf(os.Stderr, "quality error: beatport quality must be 1-4\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
cfg.Session.Beatport.Quality = opts.quality
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +354,7 @@ func main() {
|
||||
var sopts searchOptions
|
||||
if len(os.Args) < 5 {
|
||||
if !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
fmt.Println("usage: rip search <qobuz|tidal|deezer|yandex|soundcloud> <track|album|playlist|artist|label|video> <query...> [--limit N] [--force|--ignore-db] [--no-download]")
|
||||
fmt.Println("usage: rip search <qobuz|tidal|deezer|yandex|beatport|soundcloud> <track|album|playlist|artist|label|chart|video> <query...> [--limit N] [--force|--ignore-db] [--no-download]")
|
||||
os.Exit(2)
|
||||
}
|
||||
source, mediaType, sopts, err = promptSearchInteractive(cfg.Session.CLI.MaxSearchResults)
|
||||
@@ -386,6 +392,10 @@ func main() {
|
||||
fmt.Fprintln(os.Stderr, "yandex search currently supports media types track, album, playlist, and artist")
|
||||
os.Exit(2)
|
||||
}
|
||||
if source == "beatport" && mediaType != "track" && mediaType != "album" && mediaType != "label" {
|
||||
fmt.Fprintln(os.Stderr, "beatport search currently supports media types track, album, and label")
|
||||
os.Exit(2)
|
||||
}
|
||||
if sopts.query == "" {
|
||||
fmt.Fprintln(os.Stderr, "search query cannot be empty")
|
||||
os.Exit(2)
|
||||
|
||||
+31
-3
@@ -293,12 +293,12 @@ func writeSearchResultsToFile(source, mediaType string, results []searchResult,
|
||||
}
|
||||
|
||||
func isAllowedSearchSource(source string) bool {
|
||||
return source == "qobuz" || source == "tidal" || source == "deezer" || source == "yandex" || source == "soundcloud"
|
||||
return source == "qobuz" || source == "tidal" || source == "deezer" || source == "yandex" || source == "beatport" || source == "soundcloud"
|
||||
}
|
||||
|
||||
func isAllowedMediaType(mediaType string) bool {
|
||||
switch mediaType {
|
||||
case "track", "album", "playlist", "artist", "label", "video":
|
||||
case "track", "album", "playlist", "artist", "label", "video", "chart":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@@ -318,7 +318,7 @@ func promptSearchInteractive(defaultLimit int) (string, string, searchOptions, e
|
||||
}
|
||||
|
||||
for {
|
||||
source, err := read("Source [qobuz/tidal/deezer/yandex/soundcloud]: ")
|
||||
source, err := read("Source [qobuz/tidal/deezer/yandex/beatport/soundcloud]: ")
|
||||
if err != nil {
|
||||
return "", "", searchOptions{}, err
|
||||
}
|
||||
@@ -345,6 +345,10 @@ func promptSearchInteractive(defaultLimit int) (string, string, searchOptions, e
|
||||
fmt.Println("Yandex search supports track, album, playlist, and artist only.")
|
||||
continue
|
||||
}
|
||||
if source == "beatport" && mediaType != "track" && mediaType != "album" && mediaType != "label" {
|
||||
fmt.Println("Beatport search supports track, album, and label only.")
|
||||
continue
|
||||
}
|
||||
|
||||
query, err := read("Query: ")
|
||||
if err != nil {
|
||||
@@ -590,6 +594,30 @@ func normalizeSearchResults(source, mediaType string, pages []map[string]any) []
|
||||
}
|
||||
appendUnique(searchResult{ID: id, Title: title, Artist: artist, Album: album, Date: date, Releases: releases, TrackCount: trackCount, Explicit: explicit})
|
||||
}
|
||||
case "beatport":
|
||||
items, ok := page["items"].([]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, raw := range items {
|
||||
itm, ok := raw.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
id := asString(itm["id"])
|
||||
title := asString(itm["title"])
|
||||
if title == "" {
|
||||
title = asString(itm["name"])
|
||||
}
|
||||
if version := asString(itm["version"]); version != "" {
|
||||
title += " (" + version + ")"
|
||||
}
|
||||
artist := nestedSearchString(itm, "artist", "name")
|
||||
album := nestedSearchString(itm, "album", "title")
|
||||
trackCount := firstPositiveInt(searchInt(itm["tracks_count"]), searchInt(itm["track_count"]))
|
||||
date := firstNonEmpty(asString(itm["release_date_original"]), asString(itm["release_date"]), nestedSearchString(itm, "album", "release_date_original"))
|
||||
appendUnique(searchResult{ID: id, Title: title, Artist: artist, Album: album, Date: date, TrackCount: trackCount})
|
||||
}
|
||||
}
|
||||
}
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user