OpenSubsonic: getPodcastEpisode, topSongsByArtistId, transcodeOffset (real ffmpeg seek)
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user