Always access artist images through Navidrome (proxy calls to external URLs)
This commit is contained in:
@@ -2,10 +2,7 @@ package agents
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
"github.com/navidrome/navidrome/core/artwork"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
)
|
||||
|
||||
@@ -29,25 +26,10 @@ func (p *localAgent) GetBiography(ctx context.Context, id, name, mbid string) (s
|
||||
return localBiography, nil
|
||||
}
|
||||
|
||||
func (p *localAgent) GetImages(_ context.Context, id, name, mbid string) ([]ArtistImage, error) {
|
||||
return []ArtistImage{
|
||||
p.artistImage(id, 300),
|
||||
p.artistImage(id, 174),
|
||||
p.artistImage(id, 64),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *localAgent) GetTopSongs(ctx context.Context, id, artistName, mbid string, count int) ([]Song, error) {
|
||||
return nil, nil // TODO return 5-stars and liked songs sorted by playCount
|
||||
}
|
||||
|
||||
func (p *localAgent) artistImage(id string, size int) ArtistImage {
|
||||
return ArtistImage{
|
||||
filepath.Join(consts.URLPathPublicImages, artwork.PublicLink(model.NewArtworkID(model.KindArtistArtwork, id), size)),
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(LocalAgentName, localsConstructor)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -16,7 +17,7 @@ type artistReader struct {
|
||||
cacheKey
|
||||
a *artwork
|
||||
artist model.Artist
|
||||
files []string
|
||||
files string
|
||||
}
|
||||
|
||||
func newArtistReader(ctx context.Context, artwork *artwork, artID model.ArtworkID) (*artistReader, error) {
|
||||
@@ -33,12 +34,14 @@ func newArtistReader(ctx context.Context, artwork *artwork, artID model.ArtworkI
|
||||
artist: *ar,
|
||||
}
|
||||
a.cacheKey.lastUpdate = ar.ExternalInfoUpdatedAt
|
||||
var files []string
|
||||
for _, al := range als {
|
||||
a.files = append(a.files, al.ImageFiles)
|
||||
files = append(files, al.ImageFiles)
|
||||
if a.cacheKey.lastUpdate.Before(al.UpdatedAt) {
|
||||
a.cacheKey.lastUpdate = al.UpdatedAt
|
||||
}
|
||||
}
|
||||
a.files = strings.Join(files, string(filepath.ListSeparator))
|
||||
a.cacheKey.artID = artID
|
||||
return a, nil
|
||||
}
|
||||
@@ -49,7 +52,7 @@ func (a *artistReader) LastUpdated() time.Time {
|
||||
|
||||
func (a *artistReader) Reader(ctx context.Context) (io.ReadCloser, string, error) {
|
||||
return selectImageReader(ctx, a.artID,
|
||||
//fromExternalFile()
|
||||
fromExternalFile(ctx, a.files, "artist.*"),
|
||||
fromExternalSource(ctx, a.artist),
|
||||
fromArtistPlaceholder(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user