Skip to content

Commit

Permalink
chore: change the default thread number to the CPU core number.
Browse files Browse the repository at this point in the history
  • Loading branch information
syhily committed Aug 28, 2024
1 parent f3ef9b3 commit 9ffeb17
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ linters-settings:
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand All @@ -41,6 +40,7 @@ linters-settings:
- G401
- G501
- G306
- G115
depguard:
rules:
main:
Expand All @@ -62,7 +62,6 @@ linters:
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- goconst
- gocritic
Expand Down
56 changes: 33 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ Flags:
-t, --thread int The number of download thead (default 1)
Global Flags:
-c, --config string The config path for bookhunter
--proxy string The request proxy
-a, --user-agent string The request user-agent (default "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/13.0")
--verbose Print all the logs for debugging
-c, --config string The config path for bookhunter
-k, --keyword strings The keywords for books
--proxy string The request proxy
--retry int The retry times for a failed download (default 3)
-s, --skip-error Continue to download the next book if the current book download failed (default true)
--verbose Print all the logs for debugging
```

### Register account in Talebook
Expand All @@ -91,10 +93,12 @@ Flags:
-w, --website string The talebook link
Global Flags:
-c, --config string The config path for bookhunter
--proxy string The request proxy
-a, --user-agent string The request user-agent (default "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/13.0")
--verbose Print all the logs for debugging
-c, --config string The config path for bookhunter
-k, --keyword strings The keywords for books
--proxy string The request proxy
--retry int The retry times for a failed download (default 3)
-s, --skip-error Continue to download the next book if the current book download failed (default true)
--verbose Print all the logs for debugging
```

### Download books from Talebook
Expand All @@ -116,10 +120,12 @@ Flags:
-w, --website string The talebook link
Global Flags:
-c, --config string The config path for bookhunter
--proxy string The request proxy
-a, --user-agent string The request user-agent (default "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/13.0")
--verbose Print all the logs for debugging
-c, --config string The config path for bookhunter
-k, --keyword strings The keywords for books
--proxy string The request proxy
--retry int The retry times for a failed download (default 3)
-s, --skip-error Continue to download the next book if the current book download failed (default true)
--verbose Print all the logs for debugging
```

### Download books from SoBooks
Expand All @@ -129,7 +135,7 @@ Usage:
bookhunter sobooks [flags]
Flags:
--code string The secret code for SoBooks (default "844283")
--code string The secret code for SoBooks (default "244152")
-d, --download string The book directory you want to use (default ".")
-e, --extract Extract the archive file for filtering
-f, --format strings The file formats you want to download (default [epub,azw3,mobi,pdf,zip])
Expand All @@ -140,15 +146,17 @@ Flags:
-t, --thread int The number of download thead (default 1)
Global Flags:
-c, --config string The config path for bookhunter
--proxy string The request proxy
-a, --user-agent string The request user-agent (default "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/13.0")
--verbose Print all the logs for debugging
-c, --config string The config path for bookhunter
-k, --keyword strings The keywords for books
--proxy string The request proxy
--retry int The retry times for a failed download (default 3)
-s, --skip-error Continue to download the next book if the current book download failed (default true)
--verbose Print all the logs for debugging
```

### Download books from Telegram groups

Example command: `bookhunter telegram --appID ****** --appHash ****** -k https://t.me/MothLib`
Example command: `bookhunter telegram --appID ****** --appHash ****** --thread 4 --proxy http://127.0.0.1:7890 --channelID https://t.me/sharebooks4you`

Please refer [Creating your Telegram Application](https://core.telegram.org/api/obtaining_api_id) to obtain your `appID`
and `appHash`.
Expand All @@ -173,10 +181,12 @@ Flags:
-t, --thread int The number of download thead (default 1)
Global Flags:
-c, --config string The config path for bookhunter
--proxy string The request proxy
-a, --user-agent string The request user-agent (default "Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/13.0 Firefox/13.0")
--verbose Print all the logs for debugging
-c, --config string The config path for bookhunter
-k, --keyword strings The keywords for books
--proxy string The request proxy
--retry int The retry times for a failed download (default 3)
-s, --skip-error Continue to download the next book if the current book download failed (default true)
--verbose Print all the logs for debugging
```

### Download books from Hsu Life
Expand All @@ -188,7 +198,7 @@ Usage:
bookhunter hsu [flags]
Flags:
-d, --download string The book directory you want to use (default "/Users/Yufan/Developer/bookstairs/bookhunter")
-d, --download string The book directory you want to use (default ".")
-f, --format strings The file formats you want to download (default [epub,azw3,mobi,pdf,zip])
-h, --help help for hsu
-i, --initial int The book id you want to start download (default 1)
Expand Down
3 changes: 2 additions & 1 deletion cmd/flags/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flags

import (
"os"
"runtime"
"strings"

"github.com/bookstairs/bookhunter/internal/client"
Expand Down Expand Up @@ -38,7 +39,7 @@ var (
DownloadPath, _ = os.Getwd()
InitialBookID = int64(1)
Rename = false
Thread = 1
Thread = runtime.NumCPU()
RateLimit = 30

// Telegram configurations.
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ go 1.22

require (
github.com/PuerkitoBio/goquery v1.9.2
github.com/bits-and-blooms/bitset v1.13.0
github.com/bits-and-blooms/bitset v1.14.2
github.com/corpix/uarand v0.2.0
github.com/go-resty/resty/v2 v2.13.1
github.com/go-resty/resty/v2 v2.14.0
github.com/gotd/contrib v0.20.0
github.com/gotd/td v0.105.0
github.com/gotd/td v0.108.0
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/schollz/progressbar/v3 v3.14.4
github.com/schollz/progressbar/v3 v3.14.6
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
go.uber.org/ratelimit v0.3.1
golang.org/x/net v0.27.0
golang.org/x/term v0.22.0
golang.org/x/text v0.16.0
golang.org/x/net v0.28.0
golang.org/x/term v0.23.0
golang.org/x/text v0.17.0
)

require (
Expand All @@ -35,20 +35,20 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.11 // indirect
nhooyr.io/websocket v1.8.17 // indirect
rsc.io/qr v0.2.0 // indirect
)
Loading

0 comments on commit 9ffeb17

Please sign in to comment.