From 1cdf29cebc421c125666410ef6c43fa5cf66028a Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:38:41 +0800 Subject: [PATCH] fix Quality --- main.go | 32 +++++++++++++++++--------------- main_select.go | 26 ++++++++++++++------------ 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/main.go b/main.go index 7dff4e8..20f2004 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ type Config struct { EmbyAnimatedArtwork bool `yaml:"emby-animated-artwork"` EmbedLrc bool `yaml:"embed-lrc"` EmbedCover bool `yaml:"embed-cover"` - SaveArtistCover bool `yaml:"save-artist-cover"` + SaveArtistCover bool `yaml:"save-artist-cover"` CoverSize string `yaml:"cover-size"` CoverFormat string `yaml:"cover-format"` AlacSaveFolder string `yaml:"alac-save-folder"` @@ -1334,22 +1334,24 @@ func rip(albumId string, token string, storefront string, userToken string) erro fmt.Println(singerFoldername) } singerFolder := filepath.Join(config.AlacSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_")) - manifest1, err := getInfoFromAdam(meta.Data[0].Relationships.Tracks.Data[0].ID, token, storefront) - if err != nil { - fmt.Println("Failed to get manifest.\n", err) - } - if manifest1.Attributes.ExtendedAssetUrls.EnhancedHls == "" { - fmt.Println("Unavailable in ALAC.") - } var Quality string - EnhancedHls_m3u8, err := checkM3u8(meta.Data[0].Relationships.Tracks.Data[0].ID, "album") - if strings.HasPrefix(EnhancedHls_m3u8, "http") { - manifest1.Attributes.ExtendedAssetUrls.EnhancedHls = EnhancedHls_m3u8 - } if strings.Contains(config.AlbumFolderFormat, "Quality") { - Quality, err = extractMediaQuality(manifest1.Attributes.ExtendedAssetUrls.EnhancedHls) + manifest1, err := getInfoFromAdam(meta.Data[0].Relationships.Tracks.Data[0].ID, token, storefront) if err != nil { - fmt.Println("Failed to extract quality from manifest.\n", err) + fmt.Println("Failed to get manifest.\n", err) + } else { + if manifest1.Attributes.ExtendedAssetUrls.EnhancedHls == "" { + fmt.Println("Unavailable in ALAC.\n") + } else { + EnhancedHls_m3u8, err := checkM3u8(meta.Data[0].Relationships.Tracks.Data[0].ID, "album") + if strings.HasPrefix(EnhancedHls_m3u8, "http") { + manifest1.Attributes.ExtendedAssetUrls.EnhancedHls = EnhancedHls_m3u8 + } + Quality, err = extractMediaQuality(manifest1.Attributes.ExtendedAssetUrls.EnhancedHls) + if err != nil { + fmt.Println("Failed to extract quality from manifest.\n", err) + } + } } } stringsToJoin := []string{} @@ -2420,7 +2422,7 @@ type AutoGenerated struct { Type string `json:"type"` Href string `json:"href"` Attributes struct { - Name string `json:"name"` + Name string `json:"name"` Artwork struct { Url string `json:"url"` } `json:"artwork"` diff --git a/main_select.go b/main_select.go index d46a240..6821736 100644 --- a/main_select.go +++ b/main_select.go @@ -45,7 +45,7 @@ type Config struct { EmbyAnimatedArtwork bool `yaml:"emby-animated-artwork"` EmbedLrc bool `yaml:"embed-lrc"` EmbedCover bool `yaml:"embed-cover"` - SaveArtistCover bool `yaml:"save-artist-cover"` + SaveArtistCover bool `yaml:"save-artist-cover"` CoverSize string `yaml:"cover-size"` CoverFormat string `yaml:"cover-format"` AlacSaveFolder string `yaml:"alac-save-folder"` @@ -1232,18 +1232,20 @@ func rip(albumId string, token string, storefront string, userToken string) erro } } Tag_string := strings.Join(stringsToJoin, " ") - manifest1, err := getInfoFromAdam(meta.Data[0].Relationships.Tracks.Data[0].ID, token, storefront) - if err != nil { - fmt.Println("Failed to get manifest.\n", err) - } - if manifest1.Attributes.ExtendedAssetUrls.EnhancedHls == "" { - fmt.Println("Unavailable in ALAC.") - } var Quality string if strings.Contains(config.AlbumFolderFormat, "Quality") { - Quality, err = extractMediaQuality(manifest1.Attributes.ExtendedAssetUrls.EnhancedHls) + manifest1, err := getInfoFromAdam(meta.Data[0].Relationships.Tracks.Data[0].ID, token, storefront) if err != nil { - fmt.Println("Failed to extract quality from manifest.\n", err) + fmt.Println("Failed to get manifest.\n", err) + } else { + if manifest1.Attributes.ExtendedAssetUrls.EnhancedHls == "" { + fmt.Println("Unavailable in ALAC.\n") + } else { + Quality, err = extractMediaQuality(manifest1.Attributes.ExtendedAssetUrls.EnhancedHls) + if err != nil { + fmt.Println("Failed to extract quality from manifest.\n", err) + } + } } } var albumFolder string @@ -2217,7 +2219,7 @@ type AutoGenerated struct { ID string `json:"id"` Kind string `json:"kind"` } `json:"playParams"` - IsCompilation bool `json:"isCompilation"` + IsCompilation bool `json:"isCompilation"` EditorialVideo struct { MotionDetailSquare struct { Video string `json:"video"` @@ -2239,7 +2241,7 @@ type AutoGenerated struct { Type string `json:"type"` Href string `json:"href"` Attributes struct { - Name string `json:"name"` + Name string `json:"name"` Artwork struct { Url string `json:"url"` } `json:"artwork"`