Skip to content

Commit

Permalink
add album-folder-format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Jun 4, 2024
1 parent caa7161 commit 4a6ec9e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ force-api: false
get-m3u8-from-device: false
alac-max: 192000 #192000 96000 48000 44100
atmos-max: 2768 #2768 2448
#{AlbumId} {AlbumName} {ArtistName} {ReleaseDate} {UPC} {Copyright}
#example: {ReleaseDate} - {ArtistName} - {AlbumName}({AlbumId})
album-folder-format: "{AlbumName}"
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Config struct {
CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"`
AtmosSaveFolder string `yaml:"atmos-save-folder"`
AlbumFolderFormat string `yaml:"album-folder-format"`
ForceApi bool `yaml:"force-api"`
Check string `yaml:"check"`
GetM3u8FromDevice bool `yaml:"get-m3u8-from-device"`
Expand Down Expand Up @@ -1163,7 +1164,14 @@ func rip(albumId string, token string, storefront string, userToken string) erro
}
singerFoldername = strings.TrimSpace(singerFoldername)
singerFolder := filepath.Join(config.AlacSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_"))
albumFolder := fmt.Sprintf("%s", meta.Data[0].Attributes.Name)
albumFolder := strings.NewReplacer(
"{ReleaseDate}", meta.Data[0].Attributes.ReleaseDate,
"{ArtistName}", meta.Data[0].Attributes.ArtistName,
"{AlbumName}", meta.Data[0].Attributes.Name,
"{UPC}", meta.Data[0].Attributes.Upc,
"{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId,
).Replace(config.AlbumFolderFormat)
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand Down
11 changes: 10 additions & 1 deletion main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Config struct {
CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"`
AtmosSaveFolder string `yaml:"atmos-save-folder"`
AlbumFolderFormat string `yaml:"album-folder-format"`
AtmosMax int `yaml:"atmos-max"`
}

Expand Down Expand Up @@ -1121,7 +1122,15 @@ func rip(albumId string, token string, storefront string, userToken string) erro
}
singerFoldername = strings.TrimSpace(singerFoldername)
singerFolder := filepath.Join(config.AtmosSaveFolder, forbiddenNames.ReplaceAllString(singerFoldername, "_"))
albumFolder := fmt.Sprintf("%s [Atmos]", meta.Data[0].Attributes.Name)
albumFolder := strings.NewReplacer(
"{ReleaseDate}", meta.Data[0].Attributes.ReleaseDate,
"{ArtistName}", meta.Data[0].Attributes.ArtistName,
"{AlbumName}", meta.Data[0].Attributes.Name,
"{UPC}", meta.Data[0].Attributes.Upc,
"{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId,
).Replace(config.AlbumFolderFormat)
albumFolder = fmt.Sprintf("%s [Atmos]", albumFolder)
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand Down
10 changes: 9 additions & 1 deletion main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Config struct {
CoverFormat string `yaml:"cover-format"`
AlacSaveFolder string `yaml:"alac-save-folder"`
AtmosSaveFolder string `yaml:"atmos-save-folder"`
AlbumFolderFormat string `yaml:"album-folder-format"`
AlacMax int `yaml:"alac-max"`
}

Expand Down Expand Up @@ -1124,7 +1125,14 @@ func rip(albumId string, token string, storefront string, userToken string) erro
}
singerFoldername = strings.TrimSpace(singerFoldername)
singerFolder := filepath.Join("AM-DL downloads", forbiddenNames.ReplaceAllString(singerFoldername, "_"))
albumFolder := fmt.Sprintf("%s", meta.Data[0].Attributes.Name)
albumFolder := strings.NewReplacer(
"{ReleaseDate}", meta.Data[0].Attributes.ReleaseDate,
"{ArtistName}", meta.Data[0].Attributes.ArtistName,
"{AlbumName}", meta.Data[0].Attributes.Name,
"{UPC}", meta.Data[0].Attributes.Upc,
"{Copyright}", meta.Data[0].Attributes.Copyright,
"{AlbumId}", albumId,
).Replace(config.AlbumFolderFormat)
if strings.HasSuffix(albumFolder, ".") {
albumFolder = strings.ReplaceAll(albumFolder, ".", "")
}
Expand Down

0 comments on commit 4a6ec9e

Please sign in to comment.