aabookapi

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 8 Imported by: 0

README

aabookapi Package

The aabookapi package provides functionality for interacting with the AAbook API. It includes methods for retrieving book indexes, book information, searching for books, and downloading book chapters.

Installation

To use the aabookapi package, you need to have Go installed. You can install the package using the following command:

go get github.com/hhhBooksLib/aabookLib

Usage

To use the aabookapi package, import it in your Go code:

import "github.com/hhhBooksLib/aabookLib"
Creating an AAbookClient

To create a new AAbookClient, use the NewAAbookClient function:

client := aabookapi.NewAAbookClient()

This function initializes a new AAbookClient struct and sets up the AAbook API client.

Retrieving Book Index by Page

To retrieve a list of books from a specific page of the book index, use the GetBookIndexByPage method:

books := client.GetBookIndexByPage(page, pageSize)

This method takes the page number and page size as parameters and returns a slice of IndexBook structs. Each struct contains information about a book, such as its ID, name, author, category, and cover image URL.

Retrieving Book Information

To retrieve information about a specific book by its ID, use the BookInfo method:

bookInfo := client.BookInfo(bookId)

This method takes the book ID as a parameter and returns a BookInfo struct containing detailed information about the book, including its title, author, category, description, and cover image URL.

Searching for Books

To search for books based on a keyword, page number, and order, use the Search method:

searchResults := client.Search(keyword, page, order)

This method takes the keyword, page number, and order as parameters and returns a slice of SearchBook structs. Each struct represents a book that matches the search criteria and contains information such as its ID, title, author, category, and cover image URL.

Downloading Book Chapters

To download chapters of a book by its ID, use the DownloadBook method:

chapters := client.DownloadBook(bookId)

This method takes the book ID as a parameter and returns a channel of Chapter structs. Each struct represents a downloaded chapter and contains information such as the chapter ID, title, and content. The method internally uses goroutines and channels to parallelize the download process.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultProxyIp string
View Source
var DefaultProxyPassword string
View Source
var DefaultProxyPort string
View Source
var DefaultProxyUserName string
View Source
var SearchBookOrderEnum = struct {
	DefaultOrder  string
	BookWordCount string
	TotalViews    string
	UpdateTime    string
	CreateTime    string
}{
	DefaultOrder:  "0",
	BookWordCount: "9",
	TotalViews:    "17",
	UpdateTime:    "3",
	CreateTime:    "4",
}

Functions

This section is empty.

Types

type AAbookApi

type AAbookApi struct {
	Get func(pointPath string, params url.Values) requests.HttpResultInterface
}

func NewAAbookApi

func NewAAbookApi() *AAbookApi

func (*AAbookApi) BookChapterIndexApi

func (receiver *AAbookApi) BookChapterIndexApi(bookId string) []BookChapterIndex

func (*AAbookApi) BookIndexByPageApi

func (receiver *AAbookApi) BookIndexByPageApi(pageNum, pageSize, catId, size, isFinish, updT, orderBy int) []IndexBook

func (*AAbookApi) BookInfoByIdApi

func (receiver *AAbookApi) BookInfoByIdApi(bookId string) *BookInfo

func (*AAbookApi) ChapterByChapterIdApi

func (receiver *AAbookApi) ChapterByChapterIdApi(chapterId string) *Chapter

func (*AAbookApi) SearchBookInfoByKeywordApi

func (receiver *AAbookApi) SearchBookInfoByKeywordApi(keyword string, page int, order string) []SearchBook

type AAbookClient

type AAbookClient struct {
	Api *AAbookApi
}

func NewAAbookClient

func NewAAbookClient() *AAbookClient

func (*AAbookClient) BookInfo

func (receiver *AAbookClient) BookInfo(bookId string) *BookInfo

func (*AAbookClient) DownloadBook

func (receiver *AAbookClient) DownloadBook(bookId string) chan *Chapter

func (*AAbookClient) GetBookIndexByPage

func (receiver *AAbookClient) GetBookIndexByPage(page int, pageSize int) []IndexBook

func (*AAbookClient) Search

func (receiver *AAbookClient) Search(keyword string, page int, order string) []SearchBook

type BookCatalog

type BookCatalog struct {
	Index        int    `json:"index"`
	BookId       string `json:"book_id"`
	BookName     string `json:"book_name"`
	OriginBookId string `json:"origin_book_id"`
	OriginUrl    string `json:"origin_url"`
}

type BookChapterIndex

type BookChapterIndex struct {
	BookId                  string `json:"book_id"`
	ChapterIndex            string `json:"chapter_index"`
	ChapterTitle            string `json:"chapter_title"`
	ChapterId               string `json:"chapter_id"`
	ChapterUpdateTime       string `json:"chapter_update_time"`
	ChapterContentWordCount string `json:"chapter_content_word_count"`
}

type BookInfo

type BookInfo struct {
	BookId                 string `json:"book_id"`
	BookName               string `json:"book_name"`
	BookAuthor             string `json:"book_author"`
	Description            string `json:"description"`
	CreationTime           string `json:"creation_time"`
	BookType               string `json:"book_type"`
	LastUpdatedChapterTime string `json:"last_updated_chapter_time"`
	LastUpdatedChapterName string `json:"last_updated_chapter_name"`
	BookStatus             string `json:"book_status"`
	WordCount              string `json:"word_count"`
	ViewCount              string `json:"view_count"`
	MonthCount             string `json:"month_count"`
	WeekCount              string `json:"week_count"`
	TotalRecommendedCount  string `json:"total_recommended_count"`
	MonthRecommendedCount  string `json:"month_recommended_count"`
	WeekRecommendedCount   string `json:"week_recommended_count"`
}

type Chapter

type Chapter struct {
	ChapterId      string `json:"chapter_id"`
	ChapterTitle   string `json:"chapter_title"`
	ChapterContent string `json:"chapter_content"`
}

type IndexBook

type IndexBook struct {
	Index                  int    `json:"index"`
	BookId                 string `json:"book_id"`
	BookName               string `json:"book_name"`
	BookAuthor             string `json:"book_author"`
	ViewCount              string `json:"view_count"`
	BookType               string `json:"book_type"`
	LastUpdatedChapterTime string `json:"last_updated_chapter_time"`
}

type SearchBook

type SearchBook struct {
	Index      int    `json:"index"`
	BookId     string `json:"book_id"`
	BookName   string `json:"book_name"`
	BookAuthor string `json:"book_author"`
	BookStatus string `json:"book_status"`
}

Jump to

Keyboard shortcuts

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