mirror of
https://github.com/navidrome/navidrome.git
synced 2024-09-11 20:12:54 +02:00
29 lines
532 B
Go
29 lines
532 B
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
// TODO: Should the type be encoded in the ID?
|
|
func GetEntityByID(ctx context.Context, ds model.DataStore, id string) (interface{}, error) {
|
|
ar, err := ds.Artist(ctx).Get(id)
|
|
if err == nil {
|
|
return ar, nil
|
|
}
|
|
al, err := ds.Album(ctx).Get(id)
|
|
if err == nil {
|
|
return al, nil
|
|
}
|
|
pls, err := ds.Playlist(ctx).Get(id)
|
|
if err == nil {
|
|
return pls, nil
|
|
}
|
|
mf, err := ds.MediaFile(ctx).Get(id)
|
|
if err == nil {
|
|
return mf, nil
|
|
}
|
|
return nil, err
|
|
}
|