Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Jun 5, 2024
1 parent 8562986 commit 01a8bee
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ 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
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ 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
Expand Down Expand Up @@ -1200,6 +1201,9 @@ 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.") {
Expand Down Expand Up @@ -1272,8 +1276,10 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println("Failed to extract quality from manifest.\n", err)
continue
}
if config.AddCodec{
Quality=fmt.Sprintf("ALAC %s", Quality)
}
}

songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
Expand Down
11 changes: 8 additions & 3 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ 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
Expand Down Expand Up @@ -1144,12 +1145,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro
singerFolder = filepath.Join(config.AlacSaveFolder, 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}","Atmos",
"{Quality}",Quality,
).Replace(config.PlaylistFolderFormat)
}else{
albumFolder = strings.NewReplacer(
Expand All @@ -1160,7 +1165,7 @@ 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}","Atmos",
"{Quality}",Quality,
).Replace(config.AlbumFolderFormat)
}
if meta.Data[0].Attributes.IsMasteredForItunes{
Expand Down Expand Up @@ -1209,7 +1214,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{SongName}", track.Attributes.Name,
"{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}","",
"{Quality}",Quality,
).Replace(config.SongFileFormat)
if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
Expand Down
4 changes: 2 additions & 2 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{ArtistName}", "Apple Music",
"{PlaylistName}", meta.Data[0].Attributes.Name,
"{PlaylistId}", albumId,
"{Quality}","",
"{Quality}","ALAC",
).Replace(config.PlaylistFolderFormat)
}else{
albumFolder = strings.NewReplacer(
Expand All @@ -1163,7 +1163,7 @@ 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}", "",
"{Quality}", "ALAC",
).Replace(config.AlbumFolderFormat)
}
if meta.Data[0].Attributes.IsMasteredForItunes{
Expand Down

0 comments on commit 01a8bee

Please sign in to comment.