fix: no more slashes in template variables
This commit is contained in:
19
main.go
19
main.go
@@ -93,8 +93,6 @@ func mainPath(directory string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse $DATA
|
|
||||||
|
|
||||||
files, err := os.ReadDir(directory)
|
files, err := os.ReadDir(directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -336,9 +334,9 @@ func doMoveTagged(filePath string, fileTags tag.Metadata) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmplDataPath := LibTemplatePath{
|
tmplDataPath := LibTemplatePath{
|
||||||
Album: fileTags.Album(),
|
Album: cleanTemplateVariable(fileTags.Album()),
|
||||||
AlbumArtist: fileTags.AlbumArtist(),
|
AlbumArtist: cleanTemplateVariable(fileTags.AlbumArtist()),
|
||||||
Genre: fileTags.Genre(),
|
Genre: cleanTemplateVariable(fileTags.Genre()),
|
||||||
Year: fileTags.Year(),
|
Year: fileTags.Year(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,9 +365,9 @@ func doMoveTaggedPathonly(filePath string, albumTags tag.Metadata) error {
|
|||||||
tmplPath := template.Must(template.New("libPath").Parse(libTemplatePath))
|
tmplPath := template.Must(template.New("libPath").Parse(libTemplatePath))
|
||||||
|
|
||||||
tmplData := LibTemplatePath{
|
tmplData := LibTemplatePath{
|
||||||
Album: albumTags.Album(),
|
Album: cleanTemplateVariable(albumTags.Album()),
|
||||||
AlbumArtist: albumTags.AlbumArtist(),
|
AlbumArtist: cleanTemplateVariable(albumTags.AlbumArtist()),
|
||||||
Genre: albumTags.Genre(),
|
Genre: cleanTemplateVariable(albumTags.Genre()),
|
||||||
Year: albumTags.Year(),
|
Year: albumTags.Year(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,3 +449,8 @@ func cleanPath(str string) string {
|
|||||||
re := regexp.MustCompile(`[<>:"|?*]`)
|
re := regexp.MustCompile(`[<>:"|?*]`)
|
||||||
return re.ReplaceAllString(str, "")
|
return re.ReplaceAllString(str, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanTemplateVariable(str string) string {
|
||||||
|
re := regexp.MustCompile(`[<>:"|?*/\\]`)
|
||||||
|
return re.ReplaceAllString(str, "")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user