txtxiapi

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: 10 Imported by: 0

README

txtxiapi Package

The txtxiapi package provides functionality for interacting with the txtxi.com website. It includes methods for retrieving chapter content, book indexes, tag-based book lists, and downloading long book chapters.

Installation

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

go get  github.com/hhhBooksLib/txtxiLib

Usage

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

import "github.com/hhhBooksLib/txtxiLib"
Creating a TxtxiApi Client

To create a new TxtxiApi client, use the NewTxtxiClient function:

client := txtxiapi.NewTxtxiClient()

This function initializes a new TxtxiApi struct and sets up the HTTP client for making requests to the txtxi.com website. It also supports proxy configuration if the necessary environment variables are set.

Retrieving Chapter Content

To retrieve the content of a chapter by its ID, use the ChapterByChapterIdApi method:

chapter := client.ChapterByChapterIdApi("chapterId")

This method takes a chapter ID as a parameter and returns a Chapter struct containing the chapter's ID, title, and content. If the chapter content is empty, it returns nil.

Retrieving Book Index by Page

To retrieve a list of books from the index page, use the BookIndexByPageApi method:

books := client.BookIndexByPageApi(page)

This method takes a page number as a parameter and returns a slice of IndexBookList structs. Each struct contains information about a book, including its index, ID, name, description, view count, book count, ticket count, and last updated chapter time.

Retrieving Tag-based Book Lists

To retrieve a list of books based on a tag ID and page number, use the TagBooksByTagIdApi method:

books := client.TagBooksByTagIdApi(tagId, page)

This method takes a tag ID and page number as parameters and returns a slice of IndexBookList structs. Each struct contains information about a book, including its index, ID, name, description, view count, book count, ticket count, and last updated chapter time.

Downloading Long Book Chapters

To download chapters of a long book within a specified range, use the GetDownloadLongBookChapters method:

chapters := client.GetDownloadLongBookChapters(startChapterId, endChapterId, threadNum)

This method takes the starting chapter ID, ending chapter ID, and the number of threads as parameters. It returns a channel of Chapter structs, representing the downloaded chapters. The method internally uses goroutines and channels to parallelize the download process.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 Chapter

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

type IndexBookList

type IndexBookList struct {
	Index                  int    `json:"index"`
	BookId                 string `json:"book_id"`
	BookName               string `json:"book_name"`
	Description            string `json:"description"`
	BookCount              string `json:"book_count"`
	ViewCount              string `json:"view_count"`
	TicketCount            string `json:"ticket_count"`
	LastUpdatedChapterTime string `json:"last_updated_chapter_time"`
}

type TxtxiApi

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

func NewTxtxiClient

func NewTxtxiClient() *TxtxiApi

func (*TxtxiApi) BookIndexByPageApi

func (receiver *TxtxiApi) BookIndexByPageApi(page int) []IndexBookList

func (*TxtxiApi) ChapterByChapterIdApi

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

func (*TxtxiApi) GetDownloadLongBookChapters

func (receiver *TxtxiApi) GetDownloadLongBookChapters(startChapterId, endChapterId, threadNum int) chan *Chapter

func (*TxtxiApi) TagBooksByTagIdApi

func (receiver *TxtxiApi) TagBooksByTagIdApi(tagId string, page int) []IndexBookList

Jump to

Keyboard shortcuts

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