From 211acf690b1a665a6ed0287f4d2c0b5c10987ece Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:24:54 +0800 Subject: [PATCH] 1 --- config.yaml | 10 ++++------ main.go | 7 +++---- main_atmos.go | 7 +++---- main_select.go | 8 +++++--- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/config.yaml b/config.yaml index 94707a6..5b0b76e 100644 --- a/config.yaml +++ b/config.yaml @@ -11,12 +11,12 @@ force-api: false get-m3u8-from-device: false alac-max: 192000 #192000 96000 48000 44100 atmos-max: 2768 #2768 2448 -#{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {ReleaseYear} {UPC} {Copyright} {Quality} -#example: {ReleaseYear} - {ArtistName} - {AlbumName}({AlbumId})({UPC})({Copyright}) +#{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {ReleaseYear} {UPC} {Copyright} {Quality} {Codec} +#example: {ReleaseYear} - {ArtistName} - {AlbumName}({AlbumId})({UPC})({Copyright}){Codec} album-folder-format: "{AlbumName}" -#{PlaylistId} {PlaylistName} {ArtistName} {Quality} +#{PlaylistId} {PlaylistName} {ArtistName} {Quality} {Codec} playlist-folder-format: "{PlaylistName}" -#{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} +#{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} {Codec} #example: Disk {DiscNumber} - Track {TrackNumber} {SongName} [{Quality}]" song-file-format: "{SongNumer}. {SongName}" #{ArtistId} {ArtistName} @@ -26,5 +26,3 @@ artist-folder-format: "{ArtistName}" explicit-choice : "[E]" clean-choice : "[C]" apple-master-choice : "[M]" -#if set true,Quality will change to [ALAC 24B-96.0kHz] [Atmos 768kbps] -add-codec: false diff --git a/main.go b/main.go index 73e94c9..afe77a1 100644 --- a/main.go +++ b/main.go @@ -56,7 +56,6 @@ type Config struct { Check string `yaml:"check"` GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"` AlacMax int `yaml:"alac-max"` - AddCodec bool `yaml:"add-codec"` } var config Config @@ -1200,9 +1199,6 @@ func rip(albumId string, token string, storefront string, userToken string) erro if err != nil { fmt.Println("Failed to extract quality from manifest.\n", err) } - if config.AddCodec{ - Quality=fmt.Sprintf("ALAC %s", Quality) - } } var albumFolder string if strings.Contains(albumId, "pl.") { @@ -1211,6 +1207,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{PlaylistName}", meta.Data[0].Attributes.Name, "{PlaylistId}", albumId, "{Quality}",Quality, + "{Codec}", "ALAC", ).Replace(config.PlaylistFolderFormat) }else{ albumFolder = strings.NewReplacer( @@ -1222,6 +1219,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{Copyright}", meta.Data[0].Attributes.Copyright, "{AlbumId}", albumId, "{Quality}", Quality, + "{Codec}", "ALAC", ).Replace(config.AlbumFolderFormat) } if meta.Data[0].Attributes.IsMasteredForItunes{ @@ -1286,6 +1284,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{DiscNumber}", fmt.Sprintf("%0d", track.Attributes.DiscNumber), "{TrackNumber}", fmt.Sprintf("%0d", track.Attributes.TrackNumber), "{Quality}", Quality, + "{Codec}", "ALAC", ).Replace(config.SongFileFormat) if track.Attributes.IsAppleDigitalMaster{ if config.AppleMasterChoice != ""{ diff --git a/main_atmos.go b/main_atmos.go index f34fcad..8ffcb30 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -52,7 +52,6 @@ type Config struct { CleanChoice string `yaml:"clean-choice"` AppleMasterChoice string `yaml:"apple-master-choice"` AtmosMax int `yaml:"atmos-max"` - AddCodec bool `yaml:"add-codec"` } var config Config @@ -1145,15 +1144,13 @@ func rip(albumId string, token string, storefront string, userToken string) erro singerFolder := filepath.Join(config.AtmosSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_")) var albumFolder string Quality:=fmt.Sprintf("%dkbps", config.AtmosMax-2000) - if config.AddCodec{ - Quality=fmt.Sprintf("Atmos %dkbps", config.AtmosMax-2000) - } if strings.Contains(albumId, "pl.") { albumFolder = strings.NewReplacer( "{ArtistName}", "Apple Music", "{PlaylistName}", meta.Data[0].Attributes.Name, "{PlaylistId}", albumId, "{Quality}",Quality, + "{Codec}", "Atmos", ).Replace(config.PlaylistFolderFormat) }else{ albumFolder = strings.NewReplacer( @@ -1165,6 +1162,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{Copyright}", meta.Data[0].Attributes.Copyright, "{AlbumId}", albumId, "{Quality}",Quality, + "{Codec}", "Atmos", ).Replace(config.AlbumFolderFormat) } if meta.Data[0].Attributes.IsMasteredForItunes{ @@ -1214,6 +1212,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{DiscNumber}", string(track.Attributes.DiscNumber), "{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber), "{Quality}",Quality, + "{Codec}", "Atmos", ).Replace(config.SongFileFormat) if track.Attributes.IsAppleDigitalMaster{ if config.AppleMasterChoice != ""{ diff --git a/main_select.go b/main_select.go index 9e49db7..3ec43e0 100644 --- a/main_select.go +++ b/main_select.go @@ -52,7 +52,6 @@ type Config struct { ExplicitChoice string `yaml:"explicit-choice"` CleanChoice string `yaml:"clean-choice"` AppleMasterChoice string `yaml:"apple-master-choice"` - AlacMax int `yaml:"alac-max"` } var config Config @@ -1151,7 +1150,8 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{ArtistName}", "Apple Music", "{PlaylistName}", meta.Data[0].Attributes.Name, "{PlaylistId}", albumId, - "{Quality}","ALAC", + "{Quality}","", + "{Codec}", "ALAC", ).Replace(config.PlaylistFolderFormat) }else{ albumFolder = strings.NewReplacer( @@ -1162,7 +1162,8 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{UPC}", meta.Data[0].Attributes.Upc, "{Copyright}", meta.Data[0].Attributes.Copyright, "{AlbumId}", albumId, - "{Quality}", "ALAC", + "{Quality}", "", + "{Codec}", "ALAC", ).Replace(config.AlbumFolderFormat) } if meta.Data[0].Attributes.IsMasteredForItunes{ @@ -1256,6 +1257,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro "{DiscNumber}", string(track.Attributes.DiscNumber), "{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber), "{Quality}","", + "{Codec}", "ALAC", ).Replace(config.SongFileFormat) if track.Attributes.IsAppleDigitalMaster{ if config.AppleMasterChoice != ""{