From fc2bf981fe0e9f179632d3b53cee731d73d05cd3 Mon Sep 17 00:00:00 2001 From: GenzPN <39546317+GenzPN@users.noreply.github.com> Date: Fri, 14 Feb 2025 01:05:06 +0700 Subject: [PATCH] Update Save Image Cover MV --- config.yaml | 1 + main.go | 18 ++++++++++++++++++ utils/structs/structs.go | 1 + 3 files changed, 20 insertions(+) diff --git a/config.yaml b/config.yaml index eb6a06b..51bbaa2 100644 --- a/config.yaml +++ b/config.yaml @@ -44,3 +44,4 @@ use-songinfo-for-playlist: false dl-albumcover-for-playlist: false mv-audio-type: atmos #atmos ac3 aac mv-max: 2160 +save-thumbnail-image: false #true or false of thumbnail image \ No newline at end of file diff --git a/main.go b/main.go index 2d66635..0fd066d 100644 --- a/main.go +++ b/main.go @@ -1368,6 +1368,24 @@ func mvDownloader(adamID string, saveDir string, token string, storefront string defer os.Remove(vidPath) defer os.Remove(audPath) + // Extract and save thumbnail if enabled + if Config.SaveThumbnailImage { + // Get the highest quality thumbnail URL from the MV info + thumbURL := MVInfo.Data[0].Attributes.Artwork.URL + thumbURL = strings.Replace(thumbURL, "{w}x{h}", Config.CoverSize, 1) + + // Generate base name without extension + baseThumbName := forbiddenNames.ReplaceAllString(mvSaveName, "_") + "_thumbnail" + + // Download and save thumbnail + err = writeCover(saveDir, baseThumbName, thumbURL) + if err != nil { + fmt.Println("Failed to save MV thumbnail:", err) + } else { + fmt.Println("MV thumbnail saved successfully") + } + } + return nil } diff --git a/utils/structs/structs.go b/utils/structs/structs.go index 10ebfcf..639165b 100644 --- a/utils/structs/structs.go +++ b/utils/structs/structs.go @@ -36,6 +36,7 @@ type ConfigSet struct { DlAlbumcoverForPlaylist bool `yaml:"dl-albumcover-for-playlist"` MVAudioType string `yaml:"mv-audio-type"` MVMax int `yaml:"mv-max"` + SaveThumbnailImage bool `yaml:"save-thumbnail-image"` } type Counter struct {