Fix regression: Show artwork in Music Stash when browsing by folder
This commit is contained in:
+10
-2
@@ -90,17 +90,25 @@ func (c *artwork) getImagePath(ctx context.Context, id string) (path string, las
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Trace(ctx, "Looking for media file art", "id", id)
|
log.Trace(ctx, "Looking for media file art", "id", id)
|
||||||
// if id is a mediafile cover id
|
|
||||||
|
// Check if id is a mediaFile cover id
|
||||||
var mf *model.MediaFile
|
var mf *model.MediaFile
|
||||||
mf, err = c.ds.MediaFile(ctx).Get(id)
|
mf, err = c.ds.MediaFile(ctx).Get(id)
|
||||||
|
|
||||||
|
// If it is not, may be an albumId
|
||||||
|
if err == model.ErrNotFound {
|
||||||
|
return c.getImagePath(ctx, "al-"+id)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it is a mediaFile and it has cover art, return it
|
||||||
if mf.HasCoverArt {
|
if mf.HasCoverArt {
|
||||||
return mf.Path, mf.UpdatedAt, nil
|
return mf.Path, mf.UpdatedAt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the mediafile does not have a coverArt, fallback to the album cover
|
// if the mediaFile does not have a coverArt, fallback to the album cover
|
||||||
log.Trace(ctx, "Media file does not contain art. Falling back to album art", "id", id, "albumId", "al-"+mf.AlbumID)
|
log.Trace(ctx, "Media file does not contain art. Falling back to album art", "id", id, "albumId", "al-"+mf.AlbumID)
|
||||||
return c.getImagePath(ctx, "al-"+mf.AlbumID)
|
return c.getImagePath(ctx, "al-"+mf.AlbumID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,16 @@ var _ = Describe("Artwork", func() {
|
|||||||
Expect(format).To(Equal("jpeg"))
|
Expect(format).To(Equal("jpeg"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("retrieves the album artwork by album id", func() {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
|
Expect(artwork.Get(ctx, "222", 0, buf)).To(BeNil())
|
||||||
|
|
||||||
|
_, format, err := image.Decode(bytes.NewReader(buf.Bytes()))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(format).To(Equal("jpeg"))
|
||||||
|
})
|
||||||
|
|
||||||
It("resized artwork art as requested", func() {
|
It("resized artwork art as requested", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user