feat: add beatport provider

This commit is contained in:
2026-07-10 19:21:14 +02:00
parent 2a7d259e9f
commit 537959b6ec
13 changed files with 1327 additions and 9 deletions
+31 -3
View File
@@ -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