Merge pull request #58 from GenzPN/main

Update Save Image Cover MV
This commit is contained in:
ZHAAREY 2025-02-14 10:49:45 +08:00 committed by GitHub
commit 42ca991329
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View File

@ -44,3 +44,4 @@ use-songinfo-for-playlist: false
dl-albumcover-for-playlist: false dl-albumcover-for-playlist: false
mv-audio-type: atmos #atmos ac3 aac mv-audio-type: atmos #atmos ac3 aac
mv-max: 2160 mv-max: 2160
save-thumbnail-image: false #true or false of thumbnail image

18
main.go
View File

@ -1440,6 +1440,24 @@ func mvDownloader(adamID string, saveDir string, token string, storefront string
defer os.Remove(vidPath) defer os.Remove(vidPath)
defer os.Remove(audPath) 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 return nil
} }

View File

@ -36,6 +36,7 @@ type ConfigSet struct {
DlAlbumcoverForPlaylist bool `yaml:"dl-albumcover-for-playlist"` DlAlbumcoverForPlaylist bool `yaml:"dl-albumcover-for-playlist"`
MVAudioType string `yaml:"mv-audio-type"` MVAudioType string `yaml:"mv-audio-type"`
MVMax int `yaml:"mv-max"` MVMax int `yaml:"mv-max"`
SaveThumbnailImage bool `yaml:"save-thumbnail-image"`
} }
type Counter struct { type Counter struct {