internal

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultUserAgent   = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
	SuccessStatus      = "ok"
	BookNotFoundStatus = "not_found"
)
View Source
const NoBookToDownload = -1

Variables

View Source
var (
	ErrStartBookID       = errors.New("the start book id should start from 1")
	ErrStartAndEndBookID = errors.New("start book id should below the available book id")
	ErrStorageFile       = errors.New("couldn't create file for storing download process")
)
View Source
var ErrNeedSignin = errors.New("need user account to download books")

Functions

func DecodeResponse

func DecodeResponse(resp *http.Response, data interface{}) (err error)

DecodeResponse would parse the http response into a json based content.

func EscapeFilename

func EscapeFilename(filename string) string

EscapeFilename escape the filename in *nix like systems.

func Filename

func Filename(resp *http.Response) (name string)

Filename parse the file name from Content-Disposition header. If there is no such head, we would return blank string.

func GenerateUrl

func GenerateUrl(base string, paths ...string) string

GenerateUrl would remove the "/" suffix and add schema prefix to url.

func NewCookieJar

func NewCookieJar(path string) (http.CookieJar, error)

NewCookieJar would create a cookie jar instance. It supports auto saving policy.

func NewDownloadConfig

func NewDownloadConfig() *config

NewDownloadConfig will return a default blank config.

func NewStorage

func NewStorage(start, size int64, path string) (*storage, error)

NewStorage Create a storge for save the download progress.

func NewTalebook

func NewTalebook(c *config) *talebook

NewTalebook will create the download instance.

func WrapTimeOut

func WrapTimeOut(err error) error

WrapTimeOut would convert the timeout error with a better prefix in error message.

Types

type BookListResponse

type BookListResponse struct {
	CommonResponse
	Msg   string `json:"msg"`
	Title string `json:"title"`
	Total int64  `json:"total"`
	Books []struct {
		ID int64 `json:"id"`
	} `json:"books"`
}

BookListResponse is used to return recent books.

type BookResponse

type BookResponse struct {
	CommonResponse
	Msg          string `json:"msg"`
	KindleSender string `json:"kindle_sender"`
	Book         struct {
		ID    int    `json:"id"`
		Title string `json:"title"`
		Files []struct {
			Format string `json:"format"`
			Size   int64  `json:"size"`
			Href   string `json:"href"`
		} `json:"files"`
	} `json:"book"`
}

BookResponse stands for default book information

type CommonResponse

type CommonResponse struct {
	Err string `json:"err"`
}

CommonResponse is the base response for all the requests.

type LoginResponse

type LoginResponse struct {
	CommonResponse
	Msg string `json:"msg"`
}

LoginResponse is used for login action.

Jump to

Keyboard shortcuts

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