Documentation ¶
Index ¶
- Constants
- Variables
- func Auth() error
- func GetArticleResponse[R ArticleResponse](articleID int) (R, error)
- func InitClient(cookies []*http.Cookie)
- func Login(phone, password string) ([]*http.Cookie, error)
- type Article
- type ArticleInfo
- type ArticleResponse
- type ColumnResponse
- type ErrGeekTimeAPIBadCode
- type Product
- type VideoInfo
- type VideoResponse
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
InitClient init golbal clients with cookies
Types ¶
type Article ¶ added in v0.4.1
Article ...
func GetArticles ¶
GetArticles call geektime api to get article list
type ArticleInfo ¶ added in v0.7.1
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
ErrGeekTimeAPIBadCode ...
func (ErrGeekTimeAPIBadCode) Error ¶ added in v0.3.2
func (e ErrGeekTimeAPIBadCode) Error() string
Error implements error interface
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 ...
Click to show internal directories.
Click to hide internal directories.