plugin

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

plugin

Index

Constants

View Source
const (
	DownloadResultNotStarted uint32 = iota
	DownloadResultWorking
	DownloadResultFailed
	DownloadResultFinished
)
View Source
const (
	// default value of minimal line length in Chars for FormatTxt()
	DefaultFormatMinimalLineWidthInChars = 500
	// max allowed number of newlines only line in a row for FormatTxt()
	MaxChainedNewlines = 0
	BookMarkChar       = "»"
	ParagraphPrefix    = ""
)
View Source
const SubsFileName = "golitebook.subs"

Variables

This section is empty.

Functions

func FormatTxt

func FormatTxt(lineList [][]byte, linewidth int, h func(float64)) [][]byte

func GetLocalSavePath

func GetLocalSavePath() string

func GetLocalSavedFilePath

func GetLocalSavedFilePath(bookname string) string

func GetSubsSavePath

func GetSubsSavePath() string

func InitPlugins added in v0.2.1

func InitPlugins() error

func IsPrecreatedChapterTitle

func IsPrecreatedChapterTitle(line []byte, bookMarkRune rune) bool

Types

type Plugin

type Plugin struct {
	Name   string
	Cmd    *exec.Cmd
	Port   int
	Client api.GoLitebookPluginClient
}

func NewPlugin

func NewPlugin(p string, port int) (*Plugin, error)

func (*Plugin) GetBookInfo

func (p *Plugin) GetBookInfo(bookurl string) (total int, lastch, indexurl string, err error)

GetBookInfo returns total chapter count and name of last chapter

func (*Plugin) GetDesc

func (p *Plugin) GetDesc() (string, error)

func (*Plugin) SearchBook

func (p *Plugin) SearchBook(kw string) (SearchResultList, error)

type PluginList

type PluginList map[string]*Plugin
var LoadedPlugins PluginList

func (PluginList) KillAll

func (list PluginList) KillAll()

func (PluginList) NameList

func (list PluginList) NameList() []string

type SearchResult

type SearchResult struct {
	PluginName  string
	BookName    string
	BookPageURL string
	BookSize    string
	AuthorName  string
	Status      string
	LastUpdate  time.Time
}

type SearchResultList

type SearchResultList []*SearchResult

func (SearchResultList) Fields

func (srl SearchResultList) Fields() []string

Fields return the field names

func (SearchResultList) Filter

func (srl SearchResultList) Filter(kw string, i int)

func (SearchResultList) Item

func (srl SearchResultList) Item(id int) []string

Item return item with index i, as a slice of strings, each string represents a field's value

func (SearchResultList) Len

func (srl SearchResultList) Len() int

Len return total number of items

func (SearchResultList) Sort

func (srl SearchResultList) Sort(field int, ascend bool)

type Subscription

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

func NewSubscription

func NewSubscription(name, bookurl string, pluginName string, h func(string, int, int)) *Subscription

NewSubscription create a new subscription, download whole book, via book url

func (*Subscription) MarshalJSON

func (sub *Subscription) MarshalJSON() ([]byte, error)

func (*Subscription) SetHandler

func (task *Subscription) SetHandler(h func(string, int, int))

func (*Subscription) SetStatusTxt

func (task *Subscription) SetStatusTxt(t string)

func (*Subscription) Status

func (task *Subscription) Status() uint32

func (*Subscription) UnmarshalJSON

func (sub *Subscription) UnmarshalJSON(buf []byte) error

func (*Subscription) Update

func (sub *Subscription) Update()

Update use sub.StartingChapter and getbookinfo() to update the book to the latest

type SubscriptionList

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

key is the bookname

var CurrentSubscriptions *SubscriptionList

func NewSubscriptionList

func NewSubscriptionList() *SubscriptionList

func (*SubscriptionList) Append

func (slist *SubscriptionList) Append(val *Subscription)

func (*SubscriptionList) Fields

func (slist *SubscriptionList) Fields() []string

func (*SubscriptionList) Filter

func (slist *SubscriptionList) Filter(kw string, i int)

func (*SubscriptionList) Get

func (slist *SubscriptionList) Get() []*Subscription

func (*SubscriptionList) Item

func (slist *SubscriptionList) Item(id int) []string

func (*SubscriptionList) Len

func (slist *SubscriptionList) Len() int

func (*SubscriptionList) Load

func (slist *SubscriptionList) Load() error

func (*SubscriptionList) Remove

func (slist *SubscriptionList) Remove(id int)

func (*SubscriptionList) Save

func (slist *SubscriptionList) Save() error

func (*SubscriptionList) Sort

func (slist *SubscriptionList) Sort(field int, ascend bool)

func (*SubscriptionList) Update

func (slist *SubscriptionList) Update(id int, newval *Subscription)

Jump to

Keyboard shortcuts

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