hbookerLib

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: MIT Imports: 14 Imported by: 2

README

HbookerLib

The HbookerLib package provides a client library for interacting with the Hbooker API. It allows you to perform various operations such as retrieving book information, getting chapter content, buying chapters, managing bookshelves, and more.

Installation

To install the HbookerLib package, use the following command:

go get github.com/AlexiaVeronica/hbookerLib

Usage

Import the HbookerLib package in your Go code:

import "github.com/AlexiaVeronica/hbookerLib"

Create a new client by calling the NewClient function:

client := HbookerLib.NewClient()

You can customize the client by using various options:

client := HbookerLib.NewClient(
    HbookerLib.WithLoginToken("your_login_token"),
    HbookerLib.WithAccount("your_account"),
    HbookerLib.WithVersion("your_version"),
    HbookerLib.WithDebug(),
    HbookerLib.WithOutputDebug(),
    HbookerLib.WithProxyURLArray([]string{"proxy_url_1", "proxy_url_2"}),
    HbookerLib.WithProxyURL("proxy_url"),
    HbookerLib.WithAPIBaseURL("your_api_base_url"),
    HbookerLib.WithUserAgent("your_user_agent"),
    HbookerLib.WithAndroidApiKey("your_android_api_key"),
)
Available Options
  • WithLoginToken(loginToken string) Options: Sets the login token for the client.
  • WithAccount(account string) Options: Sets the account for the client.
  • WithVersion(version string) Options: Sets the version for the client.
  • WithDebug() Options: Enables debug mode for the client.
  • WithOutputDebug() Options: Enables output debug mode for the client.
  • WithProxyURLArray(proxyURLArray []string) Options: Sets the proxy URL array for the client.
  • WithProxyURL(proxyURL string) Options: Sets the proxy URL for the client.
  • WithAPIBaseURL(apiBaseURL string) Options: Sets the API base URL for the client.
  • WithUserAgent(userAgent string) Options: Sets the user agent for the client.
  • WithAndroidApiKey(androidApiKey string) Options: Sets the Android API key for the client.

API Reference

The HbookerLib package provides the following methods:

  • GetBookInfo(bookId string) (*models.BookInfo, error): Retrieves the information of a book by its ID.
  • GetDivisionListByBookId(bookId string) ([]models.VolumeList, error): Retrieves the division list of a book by its ID.
  • GetKetByChapterId(chapterId string) (string, error): Retrieves the key of a chapter by its ID.
  • GetChapterContentAPI(chapterId, chapterKey string) (*models.ChapterInfo, error): Retrieves the content of a chapter by its ID and key.
  • GetLoginTokenAPI(username, password string) (*models.Login, error): Retrieves the login token for the specified username and password.
  • GetBuyChapterAPI(chapterId, shelfId string) (*models.ContentBuy, error): Buys a chapter with the specified ID and adds it to the specified shelf.
  • GetAutoSignAPI(device string) (*models.LoginData, error): Retrieves the auto sign information for the specified device.
  • GetUseGeetestAPI(loginName string) (*models.Geetest, error): Retrieves the geetest information for the specified login name.
  • GetGeetestRegisterAPI(UserID string) (*models.Challenge, error): Retrieves the geetest register information for the specified user ID.
  • GetBookShelfIndexesInfoAPI(shelfId string) ([]models.ShelfBookList, error): Retrieves the bookshelf indexes information for the specified shelf ID.
  • GetBookShelfInfoAPI() ([]models.ShelfList, error): Retrieves the bookshelf information.
  • GetSearchBooksAPI(keyWord string, page int) ([]models.BookInfo, error): Retrieves the search results for the specified keyword and page number.

License

This package is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API added in v0.2.0

type API struct {
	HttpRequest *req.Request
}

func (*API) DeleteValue added in v0.2.0

func (api *API) DeleteValue(deleteValue string) *API

func (*API) GetAutoSignAPI added in v0.2.0

func (api *API) GetAutoSignAPI(device string) (*hbookermodel.LoginData, error)

func (*API) GetBookInfo added in v0.2.0

func (api *API) GetBookInfo(bookId string) (*hbookermodel.BookInfo, error)

func (*API) GetBookShelfInfoAPI added in v0.2.0

func (api *API) GetBookShelfInfoAPI() (*hbookermodel.Bookshelf, error)

func (*API) GetBookcaseAPI added in v0.2.4

func (api *API) GetBookcaseAPI(shelfId string) (*hbookermodel.Bookcase, error)

func (*API) GetBuyChapterAPI added in v0.2.0

func (api *API) GetBuyChapterAPI(chapterId string) (*hbookermodel.ContentBuy, error)

func (*API) GetChapterContentAPI added in v0.2.0

func (api *API) GetChapterContentAPI(chapterId, chapterKey string) (*hbookermodel.ChapterInfo, error)

func (*API) GetChapterKey added in v0.2.0

func (api *API) GetChapterKey(chapterId string) (string, error)

func (*API) GetDivisionListByBookId added in v0.2.0

func (api *API) GetDivisionListByBookId(bookId string) ([]hbookermodel.VolumeList, error)

func (*API) GetGeetestRegisterAPI added in v0.2.0

func (api *API) GetGeetestRegisterAPI(UserID string) (*hbookermodel.GeetestFirstRegisterStruct, error)

func (*API) GetSearchBooksAPI added in v0.2.0

func (api *API) GetSearchBooksAPI(keyword string, page any) (*hbookermodel.Search, error)

func (*API) GetUseGeetestAPI added in v0.2.0

func (api *API) GetUseGeetestAPI(loginName string) (*hbookermodel.GeetestData, error)

func (*API) GetUserInfo added in v0.2.0

func (api *API) GetUserInfo() (*hbookermodel.UserInfoData, error)

func (*API) MySignLogin deprecated added in v0.2.0

func (api *API) MySignLogin(username, password, validate, challenge string) (*hbookermodel.LoginData, error)

Deprecated: MySignLogin is deprecated, hbooker has joined login verification, so this method is no longer available

type APP added in v0.2.3

type APP struct {
	// contains filtered or unexported fields
}

func (*APP) Bookshelf added in v0.2.3

func (app *APP) Bookshelf(f1 continueFunction, f2 contentFunction)

func (*APP) Download added in v0.2.3

func (app *APP) Download(bookId string, f1 continueFunction, f2 contentFunction)

func (*APP) DownloadByChapterId added in v0.2.3

func (app *APP) DownloadByChapterId(chapterId string) (*hbookermodel.ChapterInfo, error)

func (*APP) EachChapter added in v0.2.3

func (app *APP) EachChapter(bookId string, f func(hbookermodel.ChapterList))

func (*APP) Search added in v0.2.3

func (app *APP) Search(keyword string, f1 continueFunction, f2 contentFunction)

func (*APP) SetThreadNum added in v0.2.3

func (app *APP) SetThreadNum(threadNum int) *APP

type Client

type Client struct {
	LoginToken string
	Account    string

	HttpsClient *req.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Options) *Client

func (*Client) API

func (client *Client) API() *API

func (*Client) APP added in v0.2.3

func (client *Client) APP() *APP

type OptionFunc

type OptionFunc func(client *Client)

func (OptionFunc) Apply

func (f OptionFunc) Apply(client *Client)

type Options

type Options interface {
	Apply(client *Client)
}

func WithAPIBaseURL

func WithAPIBaseURL(apiBaseURL string) Options

func WithAccount

func WithAccount(account string) Options

func WithAndroidApiKey

func WithAndroidApiKey(androidApiKey string) Options

func WithDebug

func WithDebug() Options

func WithDeviceToken added in v0.2.0

func WithDeviceToken(deviceToken string) Options

func WithLoginToken

func WithLoginToken(loginToken string) Options

func WithOutputDebug

func WithOutputDebug() Options

func WithProxyURL

func WithProxyURL(proxyURL string) Options

func WithRetryCount added in v0.2.0

func WithRetryCount(retryCount int) Options

func WithVersion

func WithVersion(version string) Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL