From b2a34ab235b7ed5e82df0bb034150e1b7b1ee34c Mon Sep 17 00:00:00 2001 From: Kevin Ruffin Date: Fri, 18 Feb 2022 17:50:08 -0500 Subject: [PATCH] Adds in logging messages to the generated script. Has it store files in OS and language folders. --- main.go | 75 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/main.go b/main.go index 55ad1d9..a8ade4b 100644 --- a/main.go +++ b/main.go @@ -178,6 +178,8 @@ type DownloadLinks struct { InstallerName string Filename string Md5 string + Os string + Language string } func (dl *DownloadLinks) String() string { @@ -207,6 +209,8 @@ func getDownloadLinks(p *Product) []*DownloadLinks { } dl.InstallerName = sanitizeName(i.Name) + dl.Os = i.Os + dl.Language = i.Language links = append(links, dl) } } @@ -218,39 +222,14 @@ func sanitizeName(name string) string { // s := strings.Replace(name, " ", "_", -1) // s = strings.Replace(s, "'", "", -1) // s = strings.Replace(s, "™", "", -1) - re := regexp.MustCompile("[^0-1a-zA-Z.-_]+") + re := regexp.MustCompile("[^0-9a-zA-Z_.-]+") s := name - s = re.ReplaceAllString(s, "_") + s = re.ReplaceAllString(s, "") return s } -// func writeChecksumIfNeeded(dl *DownloadLinks, folder string) { -// // TODO: reuse an existing checksum file somehow -// res, err := client.Get(dl.Checksum) -// if err != nil { -// log.Fatalf("Failed to get file checksum info (%s): %v", dl.Checksum, err) -// } -// defer res.Body.Close() -// body, err := ioutil.ReadAll(res.Body) -// if err != nil { -// log.Fatalf("Failed to parse file checksum body (%s): %v", dl.Checksum, err) -// } -// re := regexp.MustCompile(`