OpenSubsonic: getPodcastEpisode, topSongsByArtistId, transcodeOffset (real ffmpeg seek)

This commit is contained in:
2026-08-23 08:06:12 -05:00
parent e38d31d384
commit e88f4e040c
7 changed files with 219 additions and 15 deletions
+27 -10
View File
@@ -202,20 +202,37 @@ func similarSongsFor(db *sql.DB, id string, count int) ([]*database.Song, error)
}
func handleGetTopSongs(rc *Context) *apiError {
artistName, aerr := rc.Params.Required("artist")
if aerr != nil {
return aerr
}
count := rc.Params.Int("count", 50)
db := rc.Server.DB
artist, err := database.FindArtistByName(db, artistName)
if err != nil {
rc.Response = newResponse()
rc.Response.TopSongs = &TopSongs{}
return nil
// topSongsByArtistId: an explicit artist ID (the canonical internal
// ID, same as everywhere else) takes priority over the legacy
// name-based lookup when both are given, since it's unambiguous
// where a name match can collide.
var artistID string
if id := rc.Params.Get("id"); id != "" {
artist, err := database.GetArtist(db, id)
if err != nil {
rc.Response = newResponse()
rc.Response.TopSongs = &TopSongs{}
return nil
}
artistID = artist.ID
} else {
artistName, aerr := rc.Params.Required("artist")
if aerr != nil {
return aerr
}
artist, err := database.FindArtistByName(db, artistName)
if err != nil {
rc.Response = newResponse()
rc.Response.TopSongs = &TopSongs{}
return nil
}
artistID = artist.ID
}
songs, err := database.TopSongsByArtist(db, artist.ID, count)
songs, err := database.TopSongsByArtist(db, artistID, count)
if err != nil {
return newError(ErrGeneric, err.Error())
}