Refactor getMusicDirectory

This commit is contained in:
Deluan
2020-08-13 21:52:44 -04:00
committed by Deluan Quintão
parent 15c8f4c0ef
commit f16dc5f8f8
3 changed files with 76 additions and 154 deletions
+17
View File
@@ -255,3 +255,20 @@ func ChildrenFromAlbums(ctx context.Context, als model.Albums) []responses.Child
}
return children
}
// 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
}
mf, err := ds.MediaFile(ctx).Get(id)
if err == nil {
return mf, nil
}
return nil, err
}