Skip to content

Commit

Permalink
add tag
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Jun 6, 2024
1 parent 30d4de1 commit 303c253
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 83 deletions.
4 changes: 2 additions & 2 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} {Codec}
#{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {ReleaseYear} {UPC} {Copyright} {Quality} {Codec} {Tag}
#example: {ReleaseYear} - {ArtistName} - {AlbumName}({AlbumId})({UPC})({Copyright}){Codec}
album-folder-format: "{AlbumName}"
#{PlaylistId} {PlaylistName} {ArtistName} {Quality} {Codec}
playlist-folder-format: "{PlaylistName}"
#{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} {Codec}
#{SongId} {SongNumer} {SongName} {DiscNumber} {TrackNumber} {Quality} {Codec} {Tag}
#example: Disk {DiscNumber} - Track {TrackNumber} {SongName} [{Quality}]"
song-file-format: "{SongNumer}. {SongName}"
#{ArtistId} {ArtistName}
Expand Down
62 changes: 35 additions & 27 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,23 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println("Failed to extract quality from manifest.\n", err)
}
}
stringsToJoin := []string{}
if meta.Data[0].Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")
var albumFolder string
if strings.Contains(albumId, "pl.") {
albumFolder = strings.NewReplacer(
Expand All @@ -1208,6 +1225,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{PlaylistId}", albumId,
"{Quality}",Quality,
"{Codec}", "ALAC",
"{Tag}",Tag_string,
).Replace(config.PlaylistFolderFormat)
}else{
albumFolder = strings.NewReplacer(
Expand All @@ -1220,23 +1238,9 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{AlbumId}", albumId,
"{Quality}", Quality,
"{Codec}", "ALAC",
"{Tag}",Tag_string,
).Replace(config.AlbumFolderFormat)
}
if meta.Data[0].Attributes.IsMasteredForItunes{
if config.AppleMasterChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.CleanChoice)
}
}
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand Down Expand Up @@ -1274,30 +1278,34 @@ func rip(albumId string, token string, storefront string, userToken string) erro
continue
}
}
songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", fmt.Sprintf("%0d", track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%0d", track.Attributes.TrackNumber),
"{Quality}", Quality,
"{Codec}", "ALAC",
).Replace(config.SongFileFormat)
stringsToJoin := []string{}
if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.AppleMasterChoice)
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if track.Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.ExplicitChoice)
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if track.Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.CleanChoice)
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")

songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", fmt.Sprintf("%0d", track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%0d", track.Attributes.TrackNumber),
"{Quality}", Quality,
"{Tag}",Tag_string,
"{Codec}", "ALAC",
).Replace(config.SongFileFormat)
fmt.Println(songName)
filename := fmt.Sprintf("%s.m4a", forbiddenNames.ReplaceAllString(songName, "_"))
lrcFilename := fmt.Sprintf("%s.lrc", forbiddenNames.ReplaceAllString(songName, "_"))
Expand Down
62 changes: 35 additions & 27 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,23 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println(singerFoldername)
}
singerFolder := filepath.Join(config.AtmosSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_"))
stringsToJoin := []string{}
if meta.Data[0].Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")
var albumFolder string
Quality:=fmt.Sprintf("%dkbps", config.AtmosMax-2000)
if strings.Contains(albumId, "pl.") {
Expand All @@ -1151,6 +1168,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{PlaylistId}", albumId,
"{Quality}",Quality,
"{Codec}", "Atmos",
"{Tag}",Tag_string,
).Replace(config.PlaylistFolderFormat)
}else{
albumFolder = strings.NewReplacer(
Expand All @@ -1163,23 +1181,9 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{AlbumId}", albumId,
"{Quality}",Quality,
"{Codec}", "Atmos",
"{Tag}",Tag_string,
).Replace(config.AlbumFolderFormat)
}
if meta.Data[0].Attributes.IsMasteredForItunes{
if config.AppleMasterChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.CleanChoice)
}
}
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand All @@ -1205,30 +1209,34 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println("Unavailable in ALAC.")
continue
}
songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}",Quality,
"{Codec}", "Atmos",
).Replace(config.SongFileFormat)

stringsToJoin := []string{}
if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.AppleMasterChoice)
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if track.Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.ExplicitChoice)
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if track.Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.CleanChoice)
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")
songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}",Quality,
"{Codec}", "Atmos",
"{Tag}",Tag_string,
).Replace(config.SongFileFormat)
fmt.Println(songName)
filename := fmt.Sprintf("%s.ec3", forbiddenNames.ReplaceAllString(songName, "_"))
m4afilename := fmt.Sprintf("%s.m4a", forbiddenNames.ReplaceAllString(songName, "_"))
Expand Down
61 changes: 34 additions & 27 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,23 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println(singerFoldername)
}
singerFolder := filepath.Join(config.AlacSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_"))
stringsToJoin := []string{}
if meta.Data[0].Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")
var albumFolder string
if strings.Contains(albumId, "pl.") {
albumFolder = strings.NewReplacer(
Expand All @@ -1152,6 +1169,7 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{PlaylistId}", albumId,
"{Quality}","",
"{Codec}", "ALAC",
"{Tag}",Tag_string,
).Replace(config.PlaylistFolderFormat)
}else{
albumFolder = strings.NewReplacer(
Expand All @@ -1164,23 +1182,9 @@ func rip(albumId string, token string, storefront string, userToken string) erro
"{AlbumId}", albumId,
"{Quality}", "",
"{Codec}", "ALAC",
"{Tag}",Tag_string,
).Replace(config.AlbumFolderFormat)
}
if meta.Data[0].Attributes.IsMasteredForItunes{
if config.AppleMasterChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.AppleMasterChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.ExplicitChoice)
}
}
if meta.Data[0].Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
albumFolder = fmt.Sprintf("%s %s", albumFolder,config.CleanChoice)
}
}
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand Down Expand Up @@ -1250,30 +1254,33 @@ func rip(albumId string, token string, storefront string, userToken string) erro
fmt.Println("Unavailable in ALAC.")
continue
}
songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}","",
"{Codec}", "ALAC",
).Replace(config.SongFileFormat)
stringsToJoin := []string{}
if track.Attributes.IsAppleDigitalMaster{
if config.AppleMasterChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.AppleMasterChoice)
stringsToJoin = append(stringsToJoin, config.AppleMasterChoice)
}
}
if track.Attributes.ContentRating=="explicit"{
if config.ExplicitChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.ExplicitChoice)
stringsToJoin = append(stringsToJoin, config.ExplicitChoice)
}
}
if track.Attributes.ContentRating=="clean"{
if config.CleanChoice != ""{
songName = fmt.Sprintf("%s %s", songName,config.CleanChoice)
stringsToJoin = append(stringsToJoin, config.CleanChoice)
}
}
Tag_string := strings.Join(stringsToJoin, " ")
songName := strings.NewReplacer(
"{SongId}", track.ID,
"{SongNumer}", fmt.Sprintf("%02d", trackNum),
"{SongName}", track.Attributes.Name,
"{DiscNumber}", string(track.Attributes.DiscNumber),
"{TrackNumber}", fmt.Sprintf("%02d", track.Attributes.TrackNumber),
"{Quality}","",
"{Codec}", "ALAC",
"{Tag}",Tag_string,
).Replace(config.SongFileFormat)
fmt.Println(songName)
filename := fmt.Sprintf("%s.m4a", forbiddenNames.ReplaceAllString(songName, "_"))
lrcFilename := fmt.Sprintf("%s.lrc", forbiddenNames.ReplaceAllString(songName, "_"))
Expand Down

0 comments on commit 303c253

Please sign in to comment.