adding fetching and saving an entire book

This commit is contained in:
github_username_here
2026-03-10 17:48:17 +01:00
parent 7355158ff9
commit 874ba49512
157 changed files with 31768 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ import(
"github.com/PuerkitoBio/goquery"
"strconv"
"strings"
"fmt"
)
func FetchChapter(cfg *config.Cfg , searchedChapter string) ( error){
@@ -33,12 +34,13 @@ func FetchChapter(cfg *config.Cfg , searchedChapter string) ( error){
chapterNum, err := strconv.Atoi(searchedChapter)
if err != nil{
log.Printf("searched chapter %v is not a valid number%v", searchedChapter, err)
log.Printf("searched chapter %v is not a valid number - %v", searchedChapter, err)
}
chapterText := config.Chapter{
Number: chapterNum,
}
replacer := strings.NewReplacer(
"L'Éternel", "YAHWEH",
"l'Éternel", "YAHWEH",
@@ -65,22 +67,35 @@ func FetchChapter(cfg *config.Cfg , searchedChapter string) ( error){
chapterText = StripAlternativeVersification(chapterText)
cfg.Book.Chapters = append(cfg.Book.Chapters, chapterText)
err= SaveChapter(*cfg, &chapterText)
if err != nil{
log.Printf("Error saving chapter %v in yaml format.", chapterNum)
return fmt.Errorf("Error saving chapter %v in yaml format.", chapterNum)
}
return nil
}
/*
func fecthBook (book, version string, chapterNumbers int) book, error{
failedChapter := 0
bookChapters := book{}
for i:= 1 ; i > chapterNumbers ; i++{
verses, err := fetchChapter(book, strconv.Itoa(i), version)
func FetchBook (cfg *config.Cfg) error{
chapterNum, exist := cfg.BookList[cfg.Book.Name]
if !exist {
log.Printf("%v is not a Bible book or has not been inserted yet.", cfg.Book.Name)
return fmt.Errorf("%v is not a Bible book or has not been inserted yet.", cfg.Book.Name)
}
for i:= 1 ; i <= chapterNum ; i++{
err := FetchChapter(cfg, strconv.Itoa(i))
if err != nil {
failedChapter++
log.Printf("%s", err)
log.Printf("Warning : chapter %v has not been fetched: %v", i, err)
continue
}
book.chapters = append(book,
}
return nil
}
*/