service

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArticlesURL                 = "https://time.geekbang.com/serv/v1/column/articles"
	ArticleInfoURL              = "https://time.geekbang.org/serv/v3/article/info"
	ProductListURL              = "https://time.geekbang.org/serv/v3/product/list"
	PvipProductListURL          = "https://time.geekbang.org/serv/v4/pvip/product_list"
	ArticleCommentURL           = "https://time.geekbang.org/serv/v4/comment/list"
	ArticleCommentDiscussionURL = "https://time.geekbang.org/serv/discussion/v1/root_list"
	SearchURL                   = "https://time.geekbang.org/serv/v3/search"
	ColumnInfoURL               = "https://time.geekbang.org/serv/v3/column/info"
)
View Source
const (
	TASK_STATUS_PENDING  = 0x01
	TASK_STATUS_RUNNING  = 0x02
	TASK_STATUS_FINISHED = 0x03
	TASK_STATUS_ERROR    = 0x04
)
View Source
const (
	TASK_TYPE_PRODUCT = "product"
	TASK_TYPE_ARTICLE = "article"
)

Variables

View Source
var (
	ErrorGeekAccountNotLogin = errors.New("geek account not login")
)
View Source
var MkdocsYML string
View Source
var Replaces = map[string]string{
	"/":  "-",
	"|":  "-",
	"|":  "-",
	":":  ":",
	`"`:  "“",
	"?":  "?",
	"&":  "+",
	"\t": "",
	"\b": "",
}

Functions

func ArticleAllComment

func ArticleAllComment(ctx context.Context, _, accessToken string, id int64) error

func Audio

func Audio(ctx context.Context, _ *model.Task, dowloadURL, dir, fileName string) (string, error)

func Authority

func Authority(cookies string, after func(*http.Response) error) error

func Download

func Download(ctx context.Context, x *model.Task, data geek.ArticleData) error

func FindURLWithHTML added in v0.0.8

func FindURLWithHTML(rawHtml string) ([]string, error)

func GeekTimeSearch

func GeekTimeSearch(ctx context.Context, accessToken string, req geek.SearchRequest) (*geek.SearchResponse, error)

func GetArticleComment

func GetArticleComment(ctx context.Context, _, accessToken string,
	req geek.ArticleCommentListRequest) (*geek.ArticleCommentList, error)

func GetArticleCommentDiscussion

func GetArticleCommentDiscussion(ctx context.Context, _, accessToken string,
	req geek.DiscussionListRequest) (*geek.DiscussionOriginListResponse, error)

func GetArticleInfo

func GetArticleInfo(ctx context.Context, accessToken string,
	req geek.ArticlesInfoRequest) (*geek.ArticleInfoResponse, error)

func GetArticles

func GetArticles(ctx context.Context, accessToken string,
	req geek.ArticlesListRequest) (*geek.ArticlesResponse, error)

func GetColumnInfo

func GetColumnInfo(ctx context.Context, accessToken string,
	req geek.ColumnRequest) (*geek.ColumnResponse, error)

func GetGeekUser added in v0.0.8

func GetGeekUser(r *http.Response, auth *geek.AuthResponse) (*geek.GeekUser, error)

func GetProduct

func GetProduct(ctx context.Context, accessToken string,
	req geek.DailyProductRequest) (*geek.DailyProductResponse, error)

func GetPvipProduct

func GetPvipProduct(ctx context.Context, accessToken string,
	req geek.PvipProductRequest) (*geek.ProductResponse, error)

func HTMLConvertMarkdown added in v0.0.9

func HTMLConvertMarkdown(rawHtml string) (string, error)

func HtmlURLProxyReplace

func HtmlURLProxyReplace(rawHtml string) (string, error)

func MakeDocArchive

func MakeDocArchive(_ context.Context, taskId, title, introHTML string) (*bytes.Buffer, error)

func MakeDocsite

func MakeDocsite(ctx context.Context, taskId, title, introHTML string) (string, error)

func MakeDocsiteLocal

func MakeDocsiteLocal(ctx context.Context, taskId, group, title, introHTML string, commentLen int) error

func OutputHTML

func OutputHTML(n *html.Node) string

func PorxyMatch

func PorxyMatch(uri string) bool

func Request

func Request(ctx context.Context, method, url string,
	body io.Reader, accessToken string, after func(raw []byte) error) error

func SaveCookie

func SaveCookie(cookies string, identity string, auth *geek.AuthResponse) func(r *http.Response) error

func URLProxyReplace

func URLProxyReplace(uri string) string

func VerifyFileName

func VerifyFileName(name string) string

func Video

func Video(ctx context.Context, dir, fileName string, req *PlayMeta) (string, error)

Types

type Mkdocs

type Mkdocs struct {
	SiteName string
	Navs     []Nav
}
type Nav struct {
	Index int
	Name  string
	Items []string
}

type Part

type Part struct {
	Src   string
	Dest  string
	IsKey bool
}

type PlayMeta

type PlayMeta struct {
	Spec         []byte
	LocalSpec    []byte
	KeyPath      string
	Ciphertext   string
	CipherMethod string
	Parts        []Part
}

func RewritePlay

func RewritePlay(ctx context.Context, req PlayMetaRequest) (*PlayMeta, error)

type PlayMetaRequest

type PlayMetaRequest struct {
	DowloadURL string
	Dir        string
	Filename   string
	TaskId     string
	Ciphertext []byte
	Spec       []byte
}

Jump to

Keyboard shortcuts

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