From b2bf894d038be3fb1ae7da836107a2349bd78941 Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:47:50 +0800 Subject: [PATCH] fix Various Artists --- main.go | 7 ++++++- main_atmos.go | 7 ++++++- main_select.go | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 9d6b47f..cb9deee 100644 --- a/main.go +++ b/main.go @@ -1300,11 +1300,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{ArtistName}", "Apple Music", "{ArtistId}", "", ).Replace(config.ArtistFolderFormat) - } else { + } else if len(meta.Data[0].Relationships.Artists.Data) > 0 { singerFoldername = strings.NewReplacer( "{ArtistName}", meta.Data[0].Attributes.ArtistName, "{ArtistId}", meta.Data[0].Relationships.Artists.Data[0].ID, ).Replace(config.ArtistFolderFormat) + } else { + singerFoldername = strings.NewReplacer( + "{ArtistName}", meta.Data[0].Attributes.ArtistName, + "{ArtistId}", "", + ).Replace(config.ArtistFolderFormat) } if strings.HasSuffix(singerFoldername, ".") { singerFoldername = strings.ReplaceAll(singerFoldername, ".", "") diff --git a/main_atmos.go b/main_atmos.go index 7483ea1..e6bd3c0 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -1246,11 +1246,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{ArtistName}", "Apple Music", "{ArtistId}", "", ).Replace(config.ArtistFolderFormat) - } else { + } else if len(meta.Data[0].Relationships.Artists.Data) > 0 { singerFoldername = strings.NewReplacer( "{ArtistName}", meta.Data[0].Attributes.ArtistName, "{ArtistId}", meta.Data[0].Relationships.Artists.Data[0].ID, ).Replace(config.ArtistFolderFormat) + } else { + singerFoldername = strings.NewReplacer( + "{ArtistName}", meta.Data[0].Attributes.ArtistName, + "{ArtistId}", "", + ).Replace(config.ArtistFolderFormat) } if strings.HasSuffix(singerFoldername, ".") { singerFoldername = strings.ReplaceAll(singerFoldername, ".", "") diff --git a/main_select.go b/main_select.go index 9967bfb..5dcbc3e 100644 --- a/main_select.go +++ b/main_select.go @@ -1191,11 +1191,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{ArtistName}", "Apple Music", "{ArtistId}", "", ).Replace(config.ArtistFolderFormat) - } else { + } else if len(meta.Data[0].Relationships.Artists.Data) > 0 { singerFoldername = strings.NewReplacer( "{ArtistName}", meta.Data[0].Attributes.ArtistName, "{ArtistId}", meta.Data[0].Relationships.Artists.Data[0].ID, ).Replace(config.ArtistFolderFormat) + } else { + singerFoldername = strings.NewReplacer( + "{ArtistName}", meta.Data[0].Attributes.ArtistName, + "{ArtistId}", "", + ).Replace(config.ArtistFolderFormat) } if strings.HasSuffix(singerFoldername, ".") { singerFoldername = strings.ReplaceAll(singerFoldername, ".", "")