Remove size from public image ID JWT

This commit is contained in:
Deluan
2023-01-11 18:14:34 -05:00
committed by Deluan Quintão
parent 8f0d002922
commit 69e0a266f4
11 changed files with 150 additions and 87 deletions
+3 -4
View File
@@ -10,7 +10,6 @@ import (
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/server"
"github.com/navidrome/navidrome/server/subsonic/filter"
"github.com/navidrome/navidrome/server/subsonic/responses"
"github.com/navidrome/navidrome/utils"
@@ -233,9 +232,9 @@ func (api *Router) GetArtistInfo(r *http.Request) (*responses.Subsonic, error) {
response := newResponse()
response.ArtistInfo = &responses.ArtistInfo{}
response.ArtistInfo.Biography = artist.Biography
response.ArtistInfo.SmallImageUrl = server.AbsoluteURL(r, artist.SmallImageUrl)
response.ArtistInfo.MediumImageUrl = server.AbsoluteURL(r, artist.MediumImageUrl)
response.ArtistInfo.LargeImageUrl = server.AbsoluteURL(r, artist.LargeImageUrl)
response.ArtistInfo.SmallImageUrl = publicImageURL(r, artist.CoverArtID(), 160)
response.ArtistInfo.MediumImageUrl = publicImageURL(r, artist.CoverArtID(), 320)
response.ArtistInfo.LargeImageUrl = publicImageURL(r, artist.CoverArtID(), 0)
response.ArtistInfo.LastFmUrl = artist.ExternalUrl
response.ArtistInfo.MusicBrainzID = artist.MbzArtistID
for _, s := range artist.SimilarArtists {
+12 -6
View File
@@ -5,7 +5,9 @@ import (
"fmt"
"mime"
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"
"github.com/navidrome/navidrome/consts"
@@ -90,7 +92,7 @@ func toArtist(r *http.Request, a model.Artist) responses.Artist {
AlbumCount: a.AlbumCount,
UserRating: a.Rating,
CoverArt: a.CoverArtID().String(),
ArtistImageUrl: artistCoverArtURL(r, a.CoverArtID(), 0),
ArtistImageUrl: publicImageURL(r, a.CoverArtID(), 0),
}
if a.Starred {
artist.Starred = &a.StarredAt
@@ -104,7 +106,7 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
Name: a.Name,
AlbumCount: a.AlbumCount,
CoverArt: a.CoverArtID().String(),
ArtistImageUrl: artistCoverArtURL(r, a.CoverArtID(), 0),
ArtistImageUrl: publicImageURL(r, a.CoverArtID(), 0),
UserRating: a.Rating,
}
if a.Starred {
@@ -113,10 +115,14 @@ func toArtistID3(r *http.Request, a model.Artist) responses.ArtistID3 {
return artist
}
func artistCoverArtURL(r *http.Request, artID model.ArtworkID, size int) string {
link := artwork.PublicLink(artID, size)
url := filepath.Join(consts.URLPathPublicImages, link)
return server.AbsoluteURL(r, url)
func publicImageURL(r *http.Request, artID model.ArtworkID, size int) string {
link := artwork.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 {
+1 -1
View File
@@ -112,7 +112,7 @@ func (api *Router) Search2(r *http.Request) (*responses.Subsonic, error) {
AlbumCount: artist.AlbumCount,
UserRating: artist.Rating,
CoverArt: artist.CoverArtID().String(),
ArtistImageUrl: artistCoverArtURL(r, artist.CoverArtID(), 0),
ArtistImageUrl: publicImageURL(r, artist.CoverArtID(), 0),
}
if artist.Starred {
searchResult2.Artist[i].Starred = &as[i].StarredAt