Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Jun 6, 2024
1 parent 8251a7c commit 211acf6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
10 changes: 4 additions & 6 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.") {
Expand All @@ -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(
Expand All @@ -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{
Expand Down Expand Up @@ -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 != ""{
Expand Down
7 changes: 3 additions & 4 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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{
Expand Down Expand Up @@ -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 != ""{
Expand Down
8 changes: 5 additions & 3 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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{
Expand Down Expand Up @@ -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 != ""{
Expand Down

0 comments on commit 211acf6

Please sign in to comment.