diff --git a/backend/amazon.go b/backend/amazon.go index 47d9754..a3484c5 100644 --- a/backend/amazon.go +++ b/backend/amazon.go @@ -387,6 +387,7 @@ func (a *AmazonDownloader) DownloadByURL(amazonURL, outputDir, quality, filename DiscNumber: spotifyDiscNumber, TotalDiscs: spotifyTotalDiscs, URL: spotifyURL, + Comment: spotifyURL, Copyright: spotifyCopyright, Publisher: spotifyPublisher, Description: "https://github.com/afkarxyz/SpotiFLAC", diff --git a/backend/metadata.go b/backend/metadata.go index d4a9e0a..50cd52d 100644 --- a/backend/metadata.go +++ b/backend/metadata.go @@ -28,6 +28,7 @@ type Metadata struct { DiscNumber int TotalDiscs int URL string + Comment string Copyright string Publisher string Lyrics string @@ -88,6 +89,9 @@ func EmbedMetadata(filepath string, metadata Metadata, coverPath string) error { if metadata.Description != "" { _ = cmt.Add("DESCRIPTION", metadata.Description) } + if comment := resolveMetadataComment(metadata); comment != "" { + _ = cmt.Add("COMMENT", comment) + } if metadata.ISRC != "" { _ = cmt.Add("ISRC", metadata.ISRC) @@ -166,6 +170,14 @@ func extractYear(releaseDate string) string { return releaseDate } +func resolveMetadataComment(metadata Metadata) string { + if comment := strings.TrimSpace(metadata.Comment); comment != "" { + return comment + } + + return strings.TrimSpace(metadata.URL) +} + func EmbedLyricsOnly(filepath string, lyrics string) error { if lyrics == "" { return nil @@ -891,7 +903,11 @@ func ExtractFullMetadataFromFile(filePath string) (Metadata, error) { metadata.Publisher = value case "url": metadata.URL = value - case "description", "comment": + case "comment", "comments": + if metadata.Comment == "" { + metadata.Comment = value + } + case "description": if metadata.Description == "" { metadata.Description = value } @@ -982,6 +998,16 @@ func embedMetadataToMP3(filePath string, metadata Metadata, coverPath string) er tag.AddTextFrame("TSRC", id3v2.EncodingUTF8, metadata.ISRC) } + if comment := resolveMetadataComment(metadata); comment != "" { + tag.DeleteFrames(tag.CommonID("Comments")) + tag.AddCommentFrame(id3v2.CommentFrame{ + Encoding: id3v2.EncodingUTF8, + Language: "eng", + Description: "", + Text: comment, + }) + } + if coverPath != "" && fileExists(coverPath) { tag.DeleteFrames(tag.CommonID("Attached picture")) @@ -1068,6 +1094,9 @@ func embedMetadataToM4A(filePath string, metadata Metadata, coverPath string) er if metadata.ISRC != "" { args = append(args, "-metadata", "isrc="+metadata.ISRC) } + if comment := resolveMetadataComment(metadata); comment != "" { + args = append(args, "-metadata", "comment="+comment) + } tmpOutputFile := strings.TrimSuffix(filePath, pathfilepath.Ext(filePath)) + ".tmp" + pathfilepath.Ext(filePath) defer func() { diff --git a/backend/qobuz.go b/backend/qobuz.go index bf9b349..0117a2b 100644 --- a/backend/qobuz.go +++ b/backend/qobuz.go @@ -498,6 +498,7 @@ func (q *QobuzDownloader) DownloadTrackWithISRC(isrc, outputDir, quality, filena DiscNumber: spotifyDiscNumber, TotalDiscs: spotifyTotalDiscs, URL: spotifyURL, + Comment: spotifyURL, Copyright: spotifyCopyright, Publisher: spotifyPublisher, Description: "https://github.com/afkarxyz/SpotiFLAC", diff --git a/backend/tidal.go b/backend/tidal.go index e9234d9..402c81e 100644 --- a/backend/tidal.go +++ b/backend/tidal.go @@ -551,6 +551,7 @@ func (t *TidalDownloader) DownloadByURL(tidalURL, outputDir, quality, filenameFo DiscNumber: spotifyDiscNumber, TotalDiscs: spotifyTotalDiscs, URL: spotifyURL, + Comment: spotifyURL, Copyright: spotifyCopyright, Publisher: spotifyPublisher, Description: "https://github.com/afkarxyz/SpotiFLAC", @@ -710,6 +711,7 @@ func (t *TidalDownloader) DownloadByURLWithFallback(tidalURL, outputDir, quality DiscNumber: spotifyDiscNumber, TotalDiscs: spotifyTotalDiscs, URL: spotifyURL, + Comment: spotifyURL, Copyright: spotifyCopyright, Publisher: spotifyPublisher, Description: "https://github.com/afkarxyz/SpotiFLAC",