Remove characters not allowed in windows file names. #8
This commit is contained in:
parent
4ea1218cfb
commit
dda23f4948
22
Grabazine.go
22
Grabazine.go
|
|
@ -71,12 +71,15 @@ func main() {
|
||||||
for _, issue := range issueList.Data {
|
for _, issue := range issueList.Data {
|
||||||
issuePath := mydir + "/issue/" + strconv.Itoa(issue.Id)
|
issuePath := mydir + "/issue/" + strconv.Itoa(issue.Id)
|
||||||
|
|
||||||
completeName := mydir + "/issue/" + issue.Publication.Name + " - " + issue.Name + ".pdf"
|
publicationName := RemoveBadCharacters(issue.Publication.Name)
|
||||||
|
issueName := RemoveBadCharacters(issue.Name)
|
||||||
|
|
||||||
|
completeName := mydir + "/issue/" + publicationName + " - " + issueName + ".pdf"
|
||||||
if fileExists(completeName) {
|
if fileExists(completeName) {
|
||||||
fmt.Println("Issue already found: " + issue.Publication.Name + " - " + issue.Name)
|
fmt.Println("Issue already found: " + completeName)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Println("Downloading issue: " + issue.Publication.Name + " - " + issue.Name)
|
fmt.Println("Downloading issue: " + publicationName + " - " + issueName)
|
||||||
|
|
||||||
pages := GetPages(loginToken, issue, initialToken, *zinioHostPtr)
|
pages := GetPages(loginToken, issue, initialToken, *zinioHostPtr)
|
||||||
|
|
||||||
|
|
@ -156,7 +159,6 @@ func main() {
|
||||||
err = api.RemovePagesFile(filenames[i], "", []string{"2-"}, nil)
|
err = api.RemovePagesFile(filenames[i], "", []string{"2-"}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Removing extra pages failed with %s\n.", err)
|
fmt.Printf("Removing extra pages failed with %s\n.", err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -380,3 +382,15 @@ func GetDefaultTemplate() string {
|
||||||
|
|
||||||
</html>`
|
</html>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var badCharacters = []string{"/", "\\", "<", ">", ":", "\"", "|", "?", "*"}
|
||||||
|
|
||||||
|
func RemoveBadCharacters(input string) string {
|
||||||
|
|
||||||
|
temp := input
|
||||||
|
|
||||||
|
for _, badChar := range badCharacters {
|
||||||
|
temp = strings.Replace(temp, badChar, "_", -1)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue