Fix tests and lint errors, plus a bit of refactor
This commit is contained in:
@@ -5,15 +5,11 @@ import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/server"
|
||||
"github.com/navidrome/navidrome/server/public"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
@@ -92,7 +88,7 @@ func toArtist(r *http.Request, a model.Artist) responses.Artist {
|
||||
AlbumCount: a.AlbumCount,
|
||||
UserRating: a.Rating,
|
||||
CoverArt: a.CoverArtID().String(),
|
||||
ArtistImageUrl: publicImageURL(r, a.CoverArtID(), 0),
|
||||
ArtistImageUrl: public.ImageURL(r, a.CoverArtID(), 0),
|
||||
}
|
||||
if a.Starred {
|
||||
artist.Starred = &a.StarredAt
|
||||
@@ -106,7 +102,7 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
|
||||
Name: a.Name,
|
||||
AlbumCount: a.AlbumCount,
|
||||
CoverArt: a.CoverArtID().String(),
|
||||
ArtistImageUrl: publicImageURL(r, a.CoverArtID(), 0),
|
||||
ArtistImageUrl: public.ImageURL(r, a.CoverArtID(), 0),
|
||||
UserRating: a.Rating,
|
||||
}
|
||||
if a.Starred {
|
||||
@@ -115,16 +111,6 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
|
||||
return artist
|
||||
}
|
||||
|
||||
func publicImageURL(r *http.Request, artID model.ArtworkID, size int) string {
|
||||
link := public.EncodeArtworkID(artID)
|
||||
path := filepath.Join(consts.URLPathPublicImages, link)
|
||||
params := url.Values{}
|
||||
if size > 0 {
|
||||
params.Add("size", strconv.Itoa(size))
|
||||
}
|
||||
return server.AbsoluteURL(r, path, params)
|
||||
}
|
||||
|
||||
func toGenres(genres model.Genres) *responses.Genres {
|
||||
response := make([]responses.Genre, len(genres))
|
||||
for i, g := range genres {
|
||||
|
||||
Reference in New Issue
Block a user