qishutaLib

package module
v0.0.0-...-369d0f4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 10 Imported by: 0

README

QiShuTa Library for Go

QiShuTa Library is an unofficial Go client for interacting with the QiShuTa website, which provides a large collection of electronic books that can be downloaded in TXT format for free.

Features

  • Search for books by keywords.
  • Retrieve book details including name, author, cover, description, and download link.
  • Fetch book covers as byte data.
  • Get book catalogs and chapters content.
  • Manage user bookshelf after authentication.
  • Support for setting proxies, custom user agents, and debug mode.

Installation

To install QiShuTa Library, use go get:

go get -u github.com/catnovelapi/qishutaLib

Replace your_username with your GitHub username if you have forked this project or the original author's username if you are using their package directly.

Usage

Here is a quick example to get you started:

package main

import (
    "fmt"
    "github.com/catnovelapi/qishutaLib"
)

func main() {
    client := qishutaLib.NewClient().SetBaseURL("https://www.qishuta.org")
    app := client.R()

    // Fetch details for a specific book by its ID
    bookInfo, err := app.GetBookInfo("12345")
    if err != nil {
        fmt.Println("Error fetching book info:", err)
        return
    }
    fmt.Println("Book Info:", bookInfo)

    // Retrieve the book cover image
    coverBytes, err := app.GetCover(bookInfo.Cover)
    if err != nil {
        fmt.Println("Error fetching book cover:", err)
        return
    }
    fmt.Println("Book Cover Byte Length:", len(coverBytes))

    // Search for books by keyword
    searchResults, err := app.GetSearch("keyword")
    if err != nil {
        fmt.Println("Error searching books:", err)
        return
    }
    fmt.Println("Search Results:", searchResults)

    // ... other functionalities
}

Authentication

To access personalized features such as the bookshelf, you need to authenticate:

cookie, err := app.GetCookie("username", "password")
if err != nil {
    fmt.Println("Authentication failed:", err)
    return
}
client.SetCookie(cookie)

Contributing

Contributions are welcome! Feel free to open a pull request to fix a bug or add a new feature. Please follow the existing code style and add unit tests for new logic.

License

This library is licensed under the MIT License. See the LICENSE file for details.

Disclaimer

This is an unofficial client and is not endorsed by or affiliated with QiShuTa. Use it at your own risk.


For complete documentation on how to use the QiShuTa Library, refer to the GoDoc or check the examples folder in the repository.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Replace

func Replace(selection *goquery.Selection, old string) string

Types

type APP

type APP struct {
	Request *resty.Request
	Client  *Client
}

func (*APP) GetBookInfo

func (app *APP) GetBookInfo(bookId string) (*BookInfoModel, error)

func (*APP) GetBookTypeList

func (app *APP) GetBookTypeList(typeNumber int, page int) ([]TypeListBookInfoModel, error)

func (*APP) GetBookshelf

func (app *APP) GetBookshelf() ([]BookshelfModel, error)

func (*APP) GetCatalogs

func (app *APP) GetCatalogs(bookId string) ([]CatalogModel, error)

func (*APP) GetContent

func (app *APP) GetContent(bookId string, chapterId string) (*ContentModel, error)

func (*APP) GetCookie

func (app *APP) GetCookie(username string, password string) (string, error)

func (*APP) GetCover

func (app *APP) GetCover(coverPath string) ([]byte, error)

func (*APP) GetSearch

func (app *APP) GetSearch(keyword string) ([]SearchModel, error)

type BookInfoModel

type BookInfoModel struct {
	BookId      string `json:"book_id"`
	BookName    string `json:"book_name"`
	Author      string `json:"author"`
	Cover       string `json:"cover"`
	UpdateDate  string `json:"update_date"`
	Status      string `json:"status"`
	Download    string `json:"download"`
	ClickInfo   string `json:"click_info"`
	FileSize    string `json:"file_size"`
	Description string `json:"description"`
}

type BookshelfModel

type BookshelfModel struct {
	BookId        string `json:"book_id"`
	BookName      string `json:"book_name"`
	Index         string `json:"index"`
	LatestChapter string `json:"latest_chapter"`
	UpdateDate    string `json:"update_date"`
}

type CatalogModel

type CatalogModel struct {
	BookID       string `json:"book_id"`
	ChapterIndex string `json:"chapter_index"`
	ChapterTitle string `json:"chapter_title"`
	ChapterId    string `json:"chapter_id"`
}

type Client

type Client struct {
	Lock sync.Mutex

	HTTPClient *resty.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) R

func (client *Client) R() *APP

func (*Client) SetBaseURL

func (client *Client) SetBaseURL(url string) *Client

func (*Client) SetCookie

func (client *Client) SetCookie(cookie string) *Client

func (*Client) SetDebug

func (client *Client) SetDebug() *Client

func (*Client) SetRetryCount

func (client *Client) SetRetryCount(count int) *Client

func (*Client) SetUserAgent

func (client *Client) SetUserAgent(userAgent string) *Client

type ContentModel

type ContentModel struct {
	ID           string `json:"_id" bson:"_id"`
	BookId       string `json:"book_id" bson:"book_id"`
	ChapterId    string `json:"chapter_id" bson:"chapter_id"`
	ChapterTitle string `json:"chapter_title" bson:"chapter_title"`
	Content      string `json:"content" bson:"content"`
	ChapterWord  int    `json:"chapter_word" bson:"chapter_word"`
}

type Response

type Response struct {
	*resty.Response
}

func (*Response) Bytes

func (r *Response) Bytes() []byte

func (*Response) Document

func (r *Response) Document() *goquery.Document

func (*Response) Json

func (r *Response) Json() gjson.Result

func (*Response) OK

func (r *Response) OK() bool

func (*Response) Resp

func (r *Response) Resp() *resty.Response

type ResponseInterface

type ResponseInterface interface {
	Resp() *resty.Response
	Json() gjson.Result
	String() string
	Document() *goquery.Document
	OK() bool
}

type SearchModel

type SearchModel struct {
	Index         string `json:"index"`
	BookId        string `json:"book_id"`
	BookName      string `json:"book_name"`
	BookAuthor    string `json:"book_author"`
	LatestChapter string `json:"latest_chapter"`
	Update        string `json:"update"`
}

type TypeListBookInfoModel

type TypeListBookInfoModel struct {
	Index    string `json:"index"`
	BookId   string `json:"book_id"`
	BookName string `json:"book_name"`
	Cover    string `json:"cover"`

	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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