✨ Put files in the correct subfolders
This commit is contained in:
8
main.go
8
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"minie4/itslearningdl/itslearning"
|
"minie4/itslearningdl/itslearning"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
@ -79,7 +80,7 @@ func main() {
|
|||||||
return "Downloading files"
|
return "Downloading files"
|
||||||
})
|
})
|
||||||
for _, resource := range resouceList {
|
for _, resource := range resouceList {
|
||||||
var out_path = "./out/" + course.Title + "/" + resource.Title
|
var out_path = "./out" + sanitizePath(resource.Path) + "/" + resource.Title
|
||||||
if _, err := os.Stat(out_path); err == nil {
|
if _, err := os.Stat(out_path); err == nil {
|
||||||
logger.Info("Skipping element", "course", course.Title, "element", resource.Title, "id", resource.ElementID)
|
logger.Info("Skipping element", "course", course.Title, "element", resource.Title, "id", resource.ElementID)
|
||||||
continue
|
continue
|
||||||
@ -122,6 +123,11 @@ func fetchResourcesRecursive(itsl itslearning.Itslearning, course itslearning.Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sanitizePath(path string) string {
|
||||||
|
var regex = regexp.MustCompile(`\s*?/\s*`)
|
||||||
|
return regex.ReplaceAllString(path, "/")
|
||||||
|
}
|
||||||
|
|
||||||
func appendProgress(b *uiprogress.Bar) string {
|
func appendProgress(b *uiprogress.Bar) string {
|
||||||
return fmt.Sprintf("%d/%d (%.2f%%)", b.Current(), b.Total, (float32(b.Current())/float32(b.Total))*100.0)
|
return fmt.Sprintf("%d/%d (%.2f%%)", b.Current(), b.Total, (float32(b.Current())/float32(b.Total))*100.0)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user