add artist cover download

pull/21/head
itouakirai 4 months ago committed by GitHub
parent 8ef251bbf6
commit e2b674b50e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      main_select.go

@ -45,6 +45,7 @@ type Config struct {
EmbyAnimatedArtwork bool `yaml:"emby-animated-artwork"` EmbyAnimatedArtwork bool `yaml:"emby-animated-artwork"`
EmbedLrc bool `yaml:"embed-lrc"` EmbedLrc bool `yaml:"embed-lrc"`
EmbedCover bool `yaml:"embed-cover"` EmbedCover bool `yaml:"embed-cover"`
SaveArtistCover bool `yaml:"save-artist-cover"`
CoverSize string `yaml:"cover-size"` CoverSize string `yaml:"cover-size"`
CoverFormat string `yaml:"cover-format"` CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"` AlacSaveFolder string `yaml:"alac-save-folder"`
@ -1035,7 +1036,7 @@ func getMeta(albumId string, token string, storefront string) (*AutoGenerated, e
query.Set("omit[resource]", "autos") query.Set("omit[resource]", "autos")
query.Set("include", "tracks,artists,record-labels") query.Set("include", "tracks,artists,record-labels")
query.Set("include[songs]", "artists") query.Set("include[songs]", "artists")
query.Set("fields[artists]", "name") query.Set("fields[artists]", "name,artwork")
query.Set("fields[albums:albums]", "artistName,artwork,name,releaseDate,url") query.Set("fields[albums:albums]", "artistName,artwork,name,releaseDate,url")
query.Set("fields[record-labels]", "name") query.Set("fields[record-labels]", "name")
query.Set("extend", "editorialVideo") query.Set("extend", "editorialVideo")
@ -1276,6 +1277,14 @@ func rip(albumId string, token string, storefront string, userToken string) erro
sanAlbumFolder := filepath.Join(singerFolder, forbiddenNames.ReplaceAllString(albumFolder, "_")) sanAlbumFolder := filepath.Join(singerFolder, forbiddenNames.ReplaceAllString(albumFolder, "_"))
os.MkdirAll(sanAlbumFolder, os.ModePerm) os.MkdirAll(sanAlbumFolder, os.ModePerm)
fmt.Println(albumFolder) fmt.Println(albumFolder)
//get artist cover
if config.SaveArtistCover && meta.Data[0].Relationships.Artists.Data[0].Attributes.Artwork.Url != "" {
err = writeCover(singerFolder, "folder", meta.Data[0].Relationships.Artists.Data[0].Attributes.Artwork.Url)
if err != nil {
fmt.Println("Failed to write artist cover.")
}
}
//get album cover
err = writeCover(sanAlbumFolder, "cover", meta.Data[0].Attributes.Artwork.URL) err = writeCover(sanAlbumFolder, "cover", meta.Data[0].Attributes.Artwork.URL)
if err != nil { if err != nil {
fmt.Println("Failed to write cover.") fmt.Println("Failed to write cover.")
@ -2231,6 +2240,9 @@ type AutoGenerated struct {
Href string `json:"href"` Href string `json:"href"`
Attributes struct { Attributes struct {
Name string `json:"name"` Name string `json:"name"`
Artwork struct {
Url string `json:"url"`
} `json:"artwork"`
} `json:"attributes"` } `json:"attributes"`
} `json:"data"` } `json:"data"`
} `json:"artists"` } `json:"artists"`

Loading…
Cancel
Save