pull/22/head
zhaarey 5 months ago
parent 8251a7cce1
commit 211acf690b
  1. 10
      config.yaml
  2. 7
      main.go
  3. 7
      main_atmos.go
  4. 8
      main_select.go

@ -11,12 +11,12 @@ force-api: false
get-m3u8-from-device: false get-m3u8-from-device: false
alac-max: 192000 #192000 96000 48000 44100 alac-max: 192000 #192000 96000 48000 44100
atmos-max: 2768 #2768 2448 atmos-max: 2768 #2768 2448
#{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {ReleaseYear} {UPC} {Copyright} {Quality} #{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {ReleaseYear} {UPC} {Copyright} {Quality} {Codec}
#example: {ReleaseYear} - {ArtistName} - {AlbumName}({AlbumId})({UPC})({Copyright}) #example: {ReleaseYear} - {ArtistName} - {AlbumName}({AlbumId})({UPC})({Copyright}){Codec}
album-folder-format: "{AlbumName}" album-folder-format: "{AlbumName}"
#{PlaylistId} {PlaylistName} {ArtistName} {Quality} #{PlaylistId} {PlaylistName} {ArtistName} {Quality} {Codec}
playlist-folder-format: "{PlaylistName}" playlist-folder-format: "{PlaylistName}"
#{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} #{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} {Codec}
#example: Disk {DiscNumber} - Track {TrackNumber} {SongName} [{Quality}]" #example: Disk {DiscNumber} - Track {TrackNumber} {SongName} [{Quality}]"
song-file-format: "{SongNumer}. {SongName}" song-file-format: "{SongNumer}. {SongName}"
#{ArtistId} {ArtistName} #{ArtistId} {ArtistName}
@ -26,5 +26,3 @@ artist-folder-format: "{ArtistName}"
explicit-choice : "[E]" explicit-choice : "[E]"
clean-choice : "[C]" clean-choice : "[C]"
apple-master-choice : "[M]" apple-master-choice : "[M]"
#if set true,Quality will change to [ALAC 24B-96.0kHz] [Atmos 768kbps]
add-codec: false

@ -56,7 +56,6 @@ type Config struct {
Check string `yaml:"check"` Check string `yaml:"check"`
GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"` GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"`
AlacMax int `yaml:"alac-max"` AlacMax int `yaml:"alac-max"`
AddCodec bool `yaml:"add-codec"`
} }
var config Config var config Config
@ -1200,9 +1199,6 @@ func rip(albumId string, token string, storefront string, userToken string) erro
if err != nil { if err != nil {
fmt.Println("Failed to extract quality from manifest.\n", err) fmt.Println("Failed to extract quality from manifest.\n", err)
} }
if config.AddCodec{
Quality=fmt.Sprintf("ALAC %s", Quality)
}
} }
var albumFolder string var albumFolder string
if strings.Contains(albumId, "pl.") { 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, "{PlaylistName}", meta.Data[0].Attributes.Name,
"{PlaylistId}", albumId, "{PlaylistId}", albumId,
"{Quality}",Quality, "{Quality}",Quality,
"{Codec}", "ALAC",
).Replace(config.PlaylistFolderFormat) ).Replace(config.PlaylistFolderFormat)
}else{ }else{
albumFolder = strings.NewReplacer( albumFolder = strings.NewReplacer(
@ -1222,6 +1219,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{Copyright}", meta.Data[0].Attributes.Copyright, "{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId, "{AlbumId}", albumId,
"{Quality}", Quality, "{Quality}", Quality,
"{Codec}", "ALAC",
).Replace(config.AlbumFolderFormat) ).Replace(config.AlbumFolderFormat)
} }
if meta.Data[0].Attributes.IsMasteredForItunes{ 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), "{DiscNumber}", fmt.Sprintf("%0d", track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%0d", track.Attributes.TrackNumber), "{TrackNumber}", fmt.Sprintf("%0d", track.Attributes.TrackNumber),
"{Quality}", Quality, "{Quality}", Quality,
"{Codec}", "ALAC",
).Replace(config.SongFileFormat) ).Replace(config.SongFileFormat)
if track.Attributes.IsAppleDigitalMaster{ if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{ if config.AppleMasterChoice != ""{

@ -52,7 +52,6 @@ type Config struct {
CleanChoice string `yaml:"clean-choice"` CleanChoice string `yaml:"clean-choice"`
AppleMasterChoice string `yaml:"apple-master-choice"` AppleMasterChoice string `yaml:"apple-master-choice"`
AtmosMax int `yaml:"atmos-max"` AtmosMax int `yaml:"atmos-max"`
AddCodec bool `yaml:"add-codec"`
} }
var config Config 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, "_")) singerFolder := filepath.Join(config.AtmosSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_"))
var albumFolder string var albumFolder string
Quality:=fmt.Sprintf("%dkbps", config.AtmosMax-2000) Quality:=fmt.Sprintf("%dkbps", config.AtmosMax-2000)
if config.AddCodec{
Quality=fmt.Sprintf("Atmos %dkbps", config.AtmosMax-2000)
}
if strings.Contains(albumId, "pl.") { if strings.Contains(albumId, "pl.") {
albumFolder = strings.NewReplacer( albumFolder = strings.NewReplacer(
"{ArtistName}", "Apple Music", "{ArtistName}", "Apple Music",
"{PlaylistName}", meta.Data[0].Attributes.Name, "{PlaylistName}", meta.Data[0].Attributes.Name,
"{PlaylistId}", albumId, "{PlaylistId}", albumId,
"{Quality}",Quality, "{Quality}",Quality,
"{Codec}", "Atmos",
).Replace(config.PlaylistFolderFormat) ).Replace(config.PlaylistFolderFormat)
}else{ }else{
albumFolder = strings.NewReplacer( albumFolder = strings.NewReplacer(
@ -1165,6 +1162,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{Copyright}", meta.Data[0].Attributes.Copyright, "{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId, "{AlbumId}", albumId,
"{Quality}",Quality, "{Quality}",Quality,
"{Codec}", "Atmos",
).Replace(config.AlbumFolderFormat) ).Replace(config.AlbumFolderFormat)
} }
if meta.Data[0].Attributes.IsMasteredForItunes{ 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), "{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber), "{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}",Quality, "{Quality}",Quality,
"{Codec}", "Atmos",
).Replace(config.SongFileFormat) ).Replace(config.SongFileFormat)
if track.Attributes.IsAppleDigitalMaster{ if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{ if config.AppleMasterChoice != ""{

@ -52,7 +52,6 @@ type Config struct {
ExplicitChoice string `yaml:"explicit-choice"` ExplicitChoice string `yaml:"explicit-choice"`
CleanChoice string `yaml:"clean-choice"` CleanChoice string `yaml:"clean-choice"`
AppleMasterChoice string `yaml:"apple-master-choice"` AppleMasterChoice string `yaml:"apple-master-choice"`
AlacMax int `yaml:"alac-max"`
} }
var config Config var config Config
@ -1151,7 +1150,8 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{ArtistName}", "Apple Music", "{ArtistName}", "Apple Music",
"{PlaylistName}", meta.Data[0].Attributes.Name, "{PlaylistName}", meta.Data[0].Attributes.Name,
"{PlaylistId}", albumId, "{PlaylistId}", albumId,
"{Quality}","ALAC", "{Quality}","",
"{Codec}", "ALAC",
).Replace(config.PlaylistFolderFormat) ).Replace(config.PlaylistFolderFormat)
}else{ }else{
albumFolder = strings.NewReplacer( albumFolder = strings.NewReplacer(
@ -1162,7 +1162,8 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{UPC}", meta.Data[0].Attributes.Upc, "{UPC}", meta.Data[0].Attributes.Upc,
"{Copyright}", meta.Data[0].Attributes.Copyright, "{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId, "{AlbumId}", albumId,
"{Quality}", "ALAC", "{Quality}", "",
"{Codec}", "ALAC",
).Replace(config.AlbumFolderFormat) ).Replace(config.AlbumFolderFormat)
} }
if meta.Data[0].Attributes.IsMasteredForItunes{ 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), "{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber), "{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}","", "{Quality}","",
"{Codec}", "ALAC",
).Replace(config.SongFileFormat) ).Replace(config.SongFileFormat)
if track.Attributes.IsAppleDigitalMaster{ if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{ if config.AppleMasterChoice != ""{

Loading…
Cancel
Save