Files
psalms/cmd/main.go
github_username_here 7355158ff9 refactoring with internal
2026-03-24 18:39:59 +01:00

70 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import(
"project.hechon.fr/internal/fetcher"
"log"
"os"
"strings"
"project.hechon.fr/internal/config"
)
func loadExclude(path string) (map[string]struct{}, error) {
b, err := os.ReadFile(path)
if err != nil { return nil, err }
m := make(map[string]struct{})
for _, line := range strings.Split(string(b), "\n") {
w := strings.TrimSpace(line)
if w == "" || strings.HasPrefix(w, "#") { continue }
m[w] = struct{}{}
}
return m, nil
}
func main (){
book := config.Book{
Name: "Psaumes",
Version: "LSG",
}
cfg := config.Cfg{
ConfigPath: "internal/config/",
YamlPath: "data",
HtmlPath: "Public",
BookList: map[string]int{
"ps": 150,
"pr": 31,
},
Book: book,
}
properName, err:= loadExclude(cfg.ConfigPath + "properName.txt")
if err != nil{
log.Printf("cant open the proper names file")
os.Exit(1)
}
cfg.ProperName = properName
searchedChapter := "2"
err = fetcher.FetchChapter(&cfg, searchedChapter)
if err != nil {
log.Printf("GET %s %s %s failed\n", book, searchedChapter, cfg.Book.Version)
os.Exit(1)
}
/*
for i, verse := range cfg.Book.Chapters[0].Verses{
log.Printf("==== Verse: %v ====", i+1)
fetcher.SplitInPart(verse, properName)
}
*/
os.Exit(0)
}