geektime

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProductPath ...
	ProductPath = "/serv/v3/learn/product"
	// ArticlesPath ...
	ArticlesPath = "/serv/v1/column/articles"
	// ArticleV1Path ...
	ArticleV1Path = "/serv/v1/article"
	// ColumnInfoV3Path ...
	ColumnInfoV3Path = "/serv/v3/column/info"
)
View Source
const LoginPath = "/account/ticket/login"

LoginPath ...

Variables

View Source
var (
	// ErrWrongPassword ...
	ErrWrongPassword = errors.New("密码错误, 请尝试重新登录")
	// ErrTooManyLoginAttemptTimes ...
	ErrTooManyLoginAttemptTimes = errors.New("密码输入错误次数过多,已触发验证码校验,请稍后再试")
)
View Source
var (

	// SiteCookies ...
	SiteCookies []*http.Cookie
)

Functions

func Auth added in v0.2.1

func Auth() error

Auth check if current user login is expired or login in another device

func GetArticleResponse added in v0.7.1

func GetArticleResponse[R ArticleResponse](articleID int) (R, error)

GetArticleResponse get column or video response

func InitClient added in v0.4.1

func InitClient(cookies []*http.Cookie)

InitClient init golbal clients with cookies

func Login

func Login(phone, password string) ([]*http.Cookie, error)

Login call geektime login api and return auth cookies

Types

type Article added in v0.4.1

type Article struct {
	AID   int
	Title string
}

Article ...

func GetArticles

func GetArticles(cid string) ([]Article, error)

GetArticles call geektime api to get article list

type ArticleInfo added in v0.7.1

type ArticleInfo struct {
	ArticleContent   string
	AudioDownloadURL string
}

ArticleInfo ...

func GetColumnArticleInfo added in v0.7.1

func GetColumnArticleInfo(articleID int) (ArticleInfo, error)

GetColumnArticleInfo ...

type ArticleResponse added in v0.5.1

type ArticleResponse interface {
	ColumnResponse | VideoResponse
}

ArticleResponse type constraint, column and video response are different, hls_videos field in video response is struct, but in column response its slice

type ColumnResponse added in v0.5.1

type ColumnResponse struct {
	Code int `json:"code"`
	Data struct {
		ArticleTitle     string `json:"article_title"`
		ArticleContent   string `json:"article_content"`
		AudioDownloadURL string `json:"audio_download_url"`
	} `json:"data"`
}

ColumnResponse ...

type ErrGeekTimeAPIBadCode added in v0.3.2

type ErrGeekTimeAPIBadCode struct {
	Path string
	Code int
	Msg  string
}

ErrGeekTimeAPIBadCode ...

func (ErrGeekTimeAPIBadCode) Error added in v0.3.2

func (e ErrGeekTimeAPIBadCode) Error() string

Error implements error interface

type Product added in v0.2.1

type Product struct {
	Access   bool
	ID       int
	Title    string
	Type     string
	Articles []Article
}

Product ...

func GetColumnInfo added in v0.6.1

func GetColumnInfo(productID int) (Product, error)

GetColumnInfo ..

type VideoInfo added in v0.2.1

type VideoInfo struct {
	M3U8URL string
	Size    int
}

VideoInfo ...

func GetVideoInfo added in v0.2.1

func GetVideoInfo(articleID int, quality string) (VideoInfo, error)

GetVideoInfo ...

type VideoResponse added in v0.5.1

type VideoResponse struct {
	Code int `json:"code"`
	Data struct {
		ArticleTitle string `json:"article_title"`
		HLSVideos    struct {
			SD struct {
				Size int    `json:"size"`
				URL  string `json:"url"`
			} `json:"sd"`
			HD struct {
				Size int    `json:"size"`
				URL  string `json:"url"`
			} `json:"hd"`
			LD struct {
				Size int    `json:"size"`
				URL  string `json:"url"`
			} `json:"ld"`
		} `json:"hls_videos"`
	} `json:"data"`
}

VideoResponse ...

Jump to

Keyboard shortcuts

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