geektime

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GeekBangAccountBaseURL ...
	GeekBangAccountBaseURL = "https://account.geekbang.org"
	// LoginPath ...
	LoginPath = "/account/ticket/login"
	// V1AuthPath ...
	V1AuthPath = "/serv/v1/user/auth"
)
View Source
const (
	DefaultTimeout = 10 * time.Second
	// Origin ...
	Origin = "Origin"
	// UserAgent ...
	UserAgent = "User-Agent"
	// DefaultUserAgent ...
	DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"
)
View Source
const (
	// GeekBangEnterpriseBaseURL is geekbang enterprise base URL
	GeekBangEnterpriseBaseURL = "https://b.geekbang.org"
	// V1EnterpriseCourseInfoPath used in enterprise course product info
	V1EnterpriseCourseInfoPath = "/app/v1/course/info"
	// V1EnterpriseArticlesInfoPath used in enterprise course articles info
	V1EnterpriseArticlesInfoPath = "/app/v1/course/articles"
	// V1EnterpriseArticleDetailPath used in enterprise course article detail info
	V1EnterpriseArticleDetailPath = "/app/v1/article/detail"
	// V1EnterpriseVideoPlayAuthPath used in enterprise course video play auth
	V1EnterpriseVideoPlayAuthPath = "/app/v1/source_auth/video_play_auth"
)
View Source
const (
	// DefaultBaseURL ...
	DefaultBaseURL = "https://time.geekbang.org"

	// V1ColumnArticlesPath get all articles summary info in one column
	V1ColumnArticlesPath = "/serv/v1/column/articles"
	// V1ArticlePath used in normal column
	V1ArticlePath = "/serv/v1/article"
	// V3ColumnInfoPath used in get normal column/video info
	V3ColumnInfoPath = "/serv/v3/column/info"
	// V3ProductInfoPath used in get daily lesson, qconplus product info
	V3ProductInfoPath = "/serv/v3/product/info"
	// V3ArticleInfoPath used in normal video, daily lesson, qconplus
	V3ArticleInfoPath = "/serv/v3/article/info"
	// V3VideoPlayAuthPath used in normal video, daily lesson, qconplus video play auth
	V3VideoPlayAuthPath = "/serv/v3/source_auth/video_play_auth"

	// GeekBangCookieDomain ...
	GeekBangCookieDomain = ".geekbang.org"

	// GCID ...
	GCID = "GCID"
	// GCESS ...
	GCESS = "GCESS"
)
View Source
const (
	// GeekBangUniversityBaseURL ...
	GeekBangUniversityBaseURL = "https://u.geekbang.org"

	// UniversityV1VideoPlayAuthPath used in university video play auth
	UniversityV1VideoPlayAuthPath = "/serv/v1/video/play-auth"
	// UniversityV1MyClassInfoPath get university class info and all articles info in it
	UniversityV1MyClassInfoPath = "/serv/v1/myclass/info"
)

Variables

View Source
var (
	// ErrWrongPassword ...
	ErrWrongPassword = errors.New("密码错误, 请尝试重新登录")
	// ErrTooManyLoginAttemptTimes ...
	ErrTooManyLoginAttemptTimes = errors.New("密码输入错误次数过多,已触发验证码校验,请稍后再试")
	// ErrGeekTimeRateLimit ...
	ErrGeekTimeRateLimit = errors.New("已触发限流, 你可以选择重新登录/重新获取 cookie, 或者稍后再试, 然后生成剩余的文章")
	// ErrAuthFailed ...
	ErrAuthFailed = errors.New("当前账户在其他设备登录或者登录已经过期, 请尝试重新登录")
)

Functions

func Auth added in v0.2.1

func Auth(cs []*http.Cookie) error

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

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
	SectionTitle string
	Title        string
}

Article ...

type Client added in v0.10.1

type Client struct {
	RestyClient *resty.Client
	Cookies     []*http.Cookie
}

A Client manages communication with the Geektime API.

func NewClient added in v0.10.1

func NewClient(cs []*http.Cookie) *Client

NewClient returns a new Geektime API client.

func (*Client) CourseInfo added in v0.11.1

func (c *Client) CourseInfo(productID int) (Course, error)

CourseInfo get narmal geektime course info

func (*Client) EnterpriseCourseInfo added in v0.11.1

func (c *Client) EnterpriseCourseInfo(id int) (Course, error)

EnterpriseCourseInfo get enterprise course info

func (*Client) EnterpriseVideoPlayAuth added in v0.11.1

func (c *Client) EnterpriseVideoPlayAuth(articleID, videoID string) (string, error)

EnterpriseVideoPlayAuth get enterprise play auth string

func (*Client) ProductInfo added in v0.10.1

func (c *Client) ProductInfo(productID int) (response.V3ProductInfoResponse, error)

ProductInfo used to get daily lesson or qconplus product info

func (*Client) UniversityCourseInfo added in v0.11.1

func (c *Client) UniversityCourseInfo(classID int) (Course, error)

UniversityCourseInfo get university class info

func (*Client) UniversityVideoPlayAuth added in v0.10.1

func (c *Client) UniversityVideoPlayAuth(articleID, classID int) (response.V1VideoPlayAuthResponse, error)

UniversityVideoPlayAuth get university play auth string

func (*Client) V1ArticleInfo added in v0.10.1

func (c *Client) V1ArticleInfo(articleID int) (response.V1ArticleResponse, error)

V1ArticleInfo ...

func (*Client) V1EnterpriseArticleDetail added in v0.11.1

func (c *Client) V1EnterpriseArticleDetail(articleID string) (response.V1EnterpriseArticlesDetailResponse, error)

V1EnterpriseArticleDetail get enterprise article detail

func (*Client) V3ArticleInfo added in v0.10.1

func (c *Client) V3ArticleInfo(articleID int) (response.V3ArticleInfoResponse, error)

V3ArticleInfo used to get daily lesson or qconplus article info

func (*Client) VideoPlayAuth added in v0.10.1

func (c *Client) VideoPlayAuth(articleID, sourceType int, videoID string) (string, error)

VideoPlayAuth get play auth string

type Course added in v0.11.1

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

Course ...

type ErrGeekTimeAPIBadCode added in v0.3.2

type ErrGeekTimeAPIBadCode struct {
	Path           string
	ResponseString string
}

ErrGeekTimeAPIBadCode ...

func (ErrGeekTimeAPIBadCode) Error added in v0.3.2

func (e ErrGeekTimeAPIBadCode) Error() string

Error implements error interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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