.url metadata

This commit is contained in:
afkarxyz
2026-04-02 15:30:55 +07:00
parent af72ca0d01
commit fc5bda3b26
4 changed files with 34 additions and 1 deletions
+1
View File
@@ -387,6 +387,7 @@ func (a *AmazonDownloader) DownloadByURL(amazonURL, outputDir, quality, filename
DiscNumber: spotifyDiscNumber, DiscNumber: spotifyDiscNumber,
TotalDiscs: spotifyTotalDiscs, TotalDiscs: spotifyTotalDiscs,
URL: spotifyURL, URL: spotifyURL,
Comment: spotifyURL,
Copyright: spotifyCopyright, Copyright: spotifyCopyright,
Publisher: spotifyPublisher, Publisher: spotifyPublisher,
Description: "https://github.com/afkarxyz/SpotiFLAC", Description: "https://github.com/afkarxyz/SpotiFLAC",
+30 -1
View File
@@ -28,6 +28,7 @@ type Metadata struct {
DiscNumber int DiscNumber int
TotalDiscs int TotalDiscs int
URL string URL string
Comment string
Copyright string Copyright string
Publisher string Publisher string
Lyrics string Lyrics string
@@ -88,6 +89,9 @@ func EmbedMetadata(filepath string, metadata Metadata, coverPath string) error {
if metadata.Description != "" { if metadata.Description != "" {
_ = cmt.Add("DESCRIPTION", metadata.Description) _ = cmt.Add("DESCRIPTION", metadata.Description)
} }
if comment := resolveMetadataComment(metadata); comment != "" {
_ = cmt.Add("COMMENT", comment)
}
if metadata.ISRC != "" { if metadata.ISRC != "" {
_ = cmt.Add("ISRC", metadata.ISRC) _ = cmt.Add("ISRC", metadata.ISRC)
@@ -166,6 +170,14 @@ func extractYear(releaseDate string) string {
return releaseDate 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 { func EmbedLyricsOnly(filepath string, lyrics string) error {
if lyrics == "" { if lyrics == "" {
return nil return nil
@@ -891,7 +903,11 @@ func ExtractFullMetadataFromFile(filePath string) (Metadata, error) {
metadata.Publisher = value metadata.Publisher = value
case "url": case "url":
metadata.URL = value metadata.URL = value
case "description", "comment": case "comment", "comments":
if metadata.Comment == "" {
metadata.Comment = value
}
case "description":
if metadata.Description == "" { if metadata.Description == "" {
metadata.Description = value metadata.Description = value
} }
@@ -982,6 +998,16 @@ func embedMetadataToMP3(filePath string, metadata Metadata, coverPath string) er
tag.AddTextFrame("TSRC", id3v2.EncodingUTF8, metadata.ISRC) 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) { if coverPath != "" && fileExists(coverPath) {
tag.DeleteFrames(tag.CommonID("Attached picture")) tag.DeleteFrames(tag.CommonID("Attached picture"))
@@ -1068,6 +1094,9 @@ func embedMetadataToM4A(filePath string, metadata Metadata, coverPath string) er
if metadata.ISRC != "" { if metadata.ISRC != "" {
args = append(args, "-metadata", "isrc="+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) tmpOutputFile := strings.TrimSuffix(filePath, pathfilepath.Ext(filePath)) + ".tmp" + pathfilepath.Ext(filePath)
defer func() { defer func() {
+1
View File
@@ -498,6 +498,7 @@ func (q *QobuzDownloader) DownloadTrackWithISRC(isrc, outputDir, quality, filena
DiscNumber: spotifyDiscNumber, DiscNumber: spotifyDiscNumber,
TotalDiscs: spotifyTotalDiscs, TotalDiscs: spotifyTotalDiscs,
URL: spotifyURL, URL: spotifyURL,
Comment: spotifyURL,
Copyright: spotifyCopyright, Copyright: spotifyCopyright,
Publisher: spotifyPublisher, Publisher: spotifyPublisher,
Description: "https://github.com/afkarxyz/SpotiFLAC", Description: "https://github.com/afkarxyz/SpotiFLAC",
+2
View File
@@ -551,6 +551,7 @@ func (t *TidalDownloader) DownloadByURL(tidalURL, outputDir, quality, filenameFo
DiscNumber: spotifyDiscNumber, DiscNumber: spotifyDiscNumber,
TotalDiscs: spotifyTotalDiscs, TotalDiscs: spotifyTotalDiscs,
URL: spotifyURL, URL: spotifyURL,
Comment: spotifyURL,
Copyright: spotifyCopyright, Copyright: spotifyCopyright,
Publisher: spotifyPublisher, Publisher: spotifyPublisher,
Description: "https://github.com/afkarxyz/SpotiFLAC", Description: "https://github.com/afkarxyz/SpotiFLAC",
@@ -710,6 +711,7 @@ func (t *TidalDownloader) DownloadByURLWithFallback(tidalURL, outputDir, quality
DiscNumber: spotifyDiscNumber, DiscNumber: spotifyDiscNumber,
TotalDiscs: spotifyTotalDiscs, TotalDiscs: spotifyTotalDiscs,
URL: spotifyURL, URL: spotifyURL,
Comment: spotifyURL,
Copyright: spotifyCopyright, Copyright: spotifyCopyright,
Publisher: spotifyPublisher, Publisher: spotifyPublisher,
Description: "https://github.com/afkarxyz/SpotiFLAC", Description: "https://github.com/afkarxyz/SpotiFLAC",