Sanitize Filename
This commit is contained in:
parent
f014b06f88
commit
1b0a8fde36
13
main.go
13
main.go
@ -17,6 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"embed"
|
"embed"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/asticode/go-astisub"
|
"github.com/asticode/go-astisub"
|
||||||
@ -274,7 +275,9 @@ func getDownloadCommand(item Item, mpdPath string) string {
|
|||||||
|
|
||||||
command += " --auto-select"
|
command += " --auto-select"
|
||||||
|
|
||||||
filename := fmt.Sprintf("\"%s\"", item.Filename)
|
sanitizedFilename := sanitizeFilename(item.Filename)
|
||||||
|
|
||||||
|
filename := fmt.Sprintf("\"%s\"", sanitizedFilename)
|
||||||
command += fmt.Sprintf(" --save-name %s", filename)
|
command += fmt.Sprintf(" --save-name %s", filename)
|
||||||
|
|
||||||
command += fmt.Sprintf(" --mux-after-done format=%s", config.Format)
|
command += fmt.Sprintf(" --mux-after-done format=%s", config.Format)
|
||||||
@ -292,6 +295,14 @@ func getDownloadCommand(item Item, mpdPath string) string {
|
|||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sanitizeFilename(filename string) string {
|
||||||
|
filename = regexp.MustCompile(`[<>:"/\\|?*]`).ReplaceAllString(filename, "_")
|
||||||
|
|
||||||
|
filename = strings.Trim(filename, ".")
|
||||||
|
|
||||||
|
return filename
|
||||||
|
}
|
||||||
|
|
||||||
func downloadFile(item Item) error {
|
func downloadFile(item Item) error {
|
||||||
fmt.Println("Downloading:", item.Filename)
|
fmt.Println("Downloading:", item.Filename)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user