mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
feat yandex desktop downloads
This commit is contained in:
@@ -293,7 +293,7 @@ func writeSearchResultsToFile(source, mediaType string, results []searchResult,
|
||||
}
|
||||
|
||||
func isAllowedSearchSource(source string) bool {
|
||||
return source == "qobuz" || source == "tidal" || source == "deezer" || source == "soundcloud"
|
||||
return source == "qobuz" || source == "tidal" || source == "deezer" || source == "yandex" || source == "soundcloud"
|
||||
}
|
||||
|
||||
func isAllowedMediaType(mediaType string) bool {
|
||||
@@ -318,7 +318,7 @@ func promptSearchInteractive(defaultLimit int) (string, string, searchOptions, e
|
||||
}
|
||||
|
||||
for {
|
||||
source, err := read("Source [qobuz/tidal/deezer/soundcloud]: ")
|
||||
source, err := read("Source [qobuz/tidal/deezer/yandex/soundcloud]: ")
|
||||
if err != nil {
|
||||
return "", "", searchOptions{}, err
|
||||
}
|
||||
@@ -341,6 +341,10 @@ func promptSearchInteractive(defaultLimit int) (string, string, searchOptions, e
|
||||
fmt.Println("SoundCloud search supports track and playlist only.")
|
||||
continue
|
||||
}
|
||||
if source == "yandex" && mediaType != "track" && mediaType != "album" && mediaType != "playlist" && mediaType != "artist" {
|
||||
fmt.Println("Yandex search supports track, album, playlist, and artist only.")
|
||||
continue
|
||||
}
|
||||
|
||||
query, err := read("Query: ")
|
||||
if err != nil {
|
||||
@@ -544,6 +548,48 @@ func normalizeSearchResults(source, mediaType string, pages []map[string]any) []
|
||||
)
|
||||
appendUnique(searchResult{ID: id, Title: title, Artist: artist, Date: date, TrackCount: trackCount})
|
||||
}
|
||||
case "yandex":
|
||||
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"])
|
||||
}
|
||||
artist := nestedSearchString(itm, "artist", "name")
|
||||
if artist == "" {
|
||||
artist = nestedSearchString(itm, "performer", "name")
|
||||
}
|
||||
album := nestedSearchString(itm, "album", "title")
|
||||
trackCount := firstPositiveInt(
|
||||
searchInt(itm["trackCount"]),
|
||||
searchInt(itm["track_count"]),
|
||||
searchInt(itm["tracks_count"]),
|
||||
)
|
||||
explicit := searchBool(itm["explicit"])
|
||||
date := firstNonEmpty(
|
||||
asString(itm["release_date"]),
|
||||
asString(itm["releaseDate"]),
|
||||
nestedSearchString(itm, "album", "release_date"),
|
||||
nestedSearchString(itm, "album", "releaseDate"),
|
||||
)
|
||||
releases := 0
|
||||
if mediaType == "artist" {
|
||||
releases = firstPositiveInt(
|
||||
searchInt(itm["albums_count"]),
|
||||
searchInt(itm["numberOfAlbums"]),
|
||||
nestedSearchInt(itm, "albums", "total"),
|
||||
)
|
||||
}
|
||||
appendUnique(searchResult{ID: id, Title: title, Artist: artist, Album: album, Date: date, Releases: releases, TrackCount: trackCount, Explicit: explicit})
|
||||
}
|
||||
}
|
||||
}
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user