Skip to content

Commit

Permalink
feat: cap album art at 200px
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Dec 6, 2024
1 parent dbb47dd commit 02027a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/apis/applemusic/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package applemusic

import (
"fmt"
"math"
"net/url"
"regexp"
"strconv"
Expand Down Expand Up @@ -64,6 +65,7 @@ func songFromSongResponse(s songResponse) song {
s.Attributes.URL = u
}

maxAlbumArtSize := 200.0
return song{
Track: s.Attributes.Name,
Artist: s.Attributes.ArtistName,
Expand All @@ -74,8 +76,8 @@ func songFromSongResponse(s songResponse) song {
AlbumArtURL: strings.ReplaceAll(strings.ReplaceAll(
s.Attributes.Artwork.URL,
"{w}",
strconv.Itoa(s.Attributes.Artwork.Width),
), "{h}", strconv.Itoa(s.Attributes.Artwork.Height)),
strconv.Itoa(int(math.Min(float64(s.Attributes.Artwork.Width), maxAlbumArtSize))),
), "{h}", strconv.Itoa(int(math.Min(float64(s.Attributes.Artwork.Height), maxAlbumArtSize)))),
URL: s.Attributes.URL,
ID: s.ID,
}
Expand Down

0 comments on commit 02027a1

Please sign in to comment.