Add files via upload

adds ability to download artwork in original format
pull/26/head
XRD37 1 month ago committed by GitHub
parent b98e4c698c
commit 45c1d91f93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      main.go

@ -1283,6 +1283,11 @@ func getSongLyrics(songId string, storefront string, token string, userToken str
func writeCover(sanAlbumFolder, name string, url string) error {
covPath := filepath.Join(sanAlbumFolder, name+"."+config.CoverFormat)
if config.CoverFormat == "original" {
ext := strings.Split(url, "/")[len(strings.Split(url, "/"))-2]
ext = ext[strings.LastIndex(ext, ".")+1:]
covPath = filepath.Join(sanAlbumFolder, name+"."+ext)
}
exists, err := fileExists(covPath)
if err != nil {
fmt.Println("Failed to check if cover exists.")
@ -1297,6 +1302,10 @@ func writeCover(sanAlbumFolder, name string, url string) error {
url = parts[0] + "{w}x{h}" + strings.Replace(parts[1], ".jpg", ".png", 1)
}
url = strings.Replace(url, "{w}x{h}", config.CoverSize, 1)
if config.CoverFormat == "original" {
url = strings.Replace(url, "https://is1-ssl.mzstatic.com/image/thumb", "https://a5.mzstatic.com/us/r1000/0", 1)
url = url[:strings.LastIndex(url, "/")]
}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err

Loading…
Cancel
Save