Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit 2d87842

Browse files
committed
Fixed go script path, added a little concurrency
1 parent 29922fc commit 2d87842

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Diff for: go-export-page-content/export.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
book := bookIdMap[fullPage.BookId]
4949
path := book.Slug
5050
if chapter, ok := chapterIdMap[fullPage.ChapterId]; ok {
51-
path = "/" + chapter.Slug
51+
path += "/" + chapter.Slug
5252
}
5353

5454
// Get the html, or markdown, content from our page along with the file name
@@ -74,14 +74,18 @@ func main() {
7474

7575
// Write the content to the filesystem
7676
fPath := filepath.Join(absPath, fName)
77-
err = os.WriteFile(fPath, []byte(content), 0644)
78-
if err != nil {
79-
panic(err)
80-
}
77+
go writeOutPageContent(fPath, content)
8178

8279
// Wait to avoid hitting rate limits
83-
time.Sleep(time.Second / 4)
80+
time.Sleep(time.Second / 6)
8481
currentCount++
8582
}
8683

8784
}
85+
86+
func writeOutPageContent(path string, content string) {
87+
err := os.WriteFile(path, []byte(content), 0644)
88+
if err != nil {
89+
panic(err)
90+
}
91+
}

Diff for: go-export-page-content/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Content will be written into a directory structure that mirrors the page's locat
55

66
Note: This is only provided as an example. The project lacks full error handling and also disables HTTPS verification for easier use with self-signed certificates.
77

8+
This project uses timeouts, and lacks async requesting, to respect potential rate limits.
9+
810
## Requirements
911

1012
[Go](https://go.dev/) is required to build this project.

0 commit comments

Comments
 (0)