remove invalid characters from generated filename (windows/linux)
This commit is contained in:
parent
793f3b5900
commit
8b5f2e035b
9
main.go
9
main.go
@ -153,7 +153,14 @@ func performDownload(ctx context.Context, cfg *config, targetUrl string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
outputFile = fmt.Sprintf(`[Loadtup] %s [%08X].mkv`, ltc.Title, hw.Sum())
|
var invalidChars *strings.Replacer
|
||||||
|
if runtime.GOOS == "windows" { // compile-time constant comparison will be elided
|
||||||
|
invalidChars = strings.NewReplacer(`"`, `_`, `*`, `_`, `<`, `_`, `>`, `_`, `?`, `_`, `\`, `_`, `|`, `_`, `/`, `_`, `:`, `_`)
|
||||||
|
} else {
|
||||||
|
invalidChars = strings.NewReplacer(`/`, `_`)
|
||||||
|
}
|
||||||
|
|
||||||
|
outputFile = fmt.Sprintf(`[Loadtup] %s [%08X].mkv`, invalidChars.Replace(ltc.Title), hw.Sum())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Rename(filepath.Join(tmpdir, "muxed.mkv"), outputFile)
|
err = os.Rename(filepath.Join(tmpdir, "muxed.mkv"), outputFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user