client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginPath     = "auth/udemy-auth/login"
	UserPath      = "users/me"
	MyCoursesPath = "users/me/subscribed-courses"
	CoursesPath   = "courses"
	Timeout       = time.Second * 600
)
View Source
const BaseURL = "https://www.udemy.com/api-2.0"
View Source
const LoginFormURL = "https://www.udemy.com/join/login-popup/?display_type=popup&response_type=json"

LOGIN

Variables

View Source
var DefaultClient = New()

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID           int           `json:"id"`
	AssetType    string        `json:"asset_type"`
	Title        string        `json:"title"`
	ExternalURL  string        `json:"external_url"`
	DownloadUrls *DownloadURLs `json:"download_urls"`
	//SlideUrls    []interface{} `json:"slide_urls"`
	StreamUrls *StreamURLs `json:"stream_urls"`
	Captions   []*Caption  `json:"captions"`
}

type Caption

type Caption struct {
	Status     int       `json:"status"`
	Locale     Locale    `json:"locale"`
	ID         int       `json:"id"`
	Source     string    `json:"source"`
	Title      string    `json:"title"`
	VideoLabel string    `json:"video_label"`
	Created    time.Time `json:"created"`
	FileName   string    `json:"file_name"`
	URL        string    `json:"url"`
}

type Chapter

type Chapter struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	ObjectIndex int    `json:"object_index"`
}

type Client

type Client struct {
	HTTPClient  *http.Client
	Credentials Credentials
}

func New

func New() *Client

func (*Client) GET

func (c *Client) GET(ctx context.Context, url string) (*http.Response, error)

GET sends a GET request to Udemy, adding a whole lot of headers in the process

func (*Client) GetCourse

func (c *Client) GetCourse(ctx context.Context, ID int) (*Course, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (*User, error)

func (*Client) ListCourses

func (c *Client) ListCourses(ctx context.Context, opt *PaginationOptions) (*Courses, error)

func (*Client) LoadCurriculum

func (c *Client) LoadCurriculum(ctx context.Context, courseID int, opt *PaginationOptions) (*Curriculum, error)

func (*Client) Login added in v0.2.0

func (c *Client) Login(ctx context.Context, email, password string) (Credentials, error)

type Course

type Course struct {
	ID             int    `json:"id"`
	Title          string `json:"title"`
	URL            string `json:"url"`
	PublishedTitle string `json:"published_title"`
}

func GetCourse added in v0.2.0

func GetCourse(ID int) (*Course, error)

type Courses

type Courses struct {
	Count    int       `json:"count"`
	Next     string    `json:"next"`
	Previous string    `json:"previous"`
	Results  []*Course `json:"results"`
}

func ListCourses added in v0.2.0

func ListCourses(opt *PaginationOptions) (*Courses, error)

type Credentials added in v0.2.0

type Credentials struct {
	ID          string
	AccessToken string
}

func Login added in v0.2.0

func Login(username, password string) (cred Credentials, err error)

type Curriculum

type Curriculum struct {
	Count    int             `json:"count"`
	Next     string          `json:"next"`
	Previous string          `json:"previous"`
	Results  CurriculumItems `json:"results"`
}

func LoadCurriculum added in v0.2.0

func LoadCurriculum(courseID int, opt *PaginationOptions) (*Curriculum, error)

type CurriculumItems added in v0.2.0

type CurriculumItems []interface{}

CurriculumItem contains either *Chapter or *Lecture items

func (*CurriculumItems) UnmarshalJSON added in v0.2.0

func (c *CurriculumItems) UnmarshalJSON(data []byte) error

type DownloadURLs

type DownloadURLs struct {
	Video []*Video `json:"Video"`
	File  []*File  `json:"File"`
	Ebook []*File  `json:"E-Book"`
}

type File

type File struct {
	Label string `json:"label"`
	File  string `json:"file"`
}

type Lecture

type Lecture struct {
	Chapter             *Chapter `json:"-"`
	ID                  int      `json:"id"`
	Title               string   `json:"title"`
	TitleCleaned        string   `json:"title_cleaned"`
	Asset               *Asset   `json:"asset"`
	SupplementaryAssets []*Asset `json:"supplementary_assets"`
	ObjectIndex         int      `json:"object_index"`
}

type Lectures

type Lectures struct {
	Count    int        `json:"count"`
	Next     string     `json:"next"`
	Previous string     `json:"previous"`
	Results  []*Lecture `json:"results"`
}

type Locale

type Locale struct {
	Locale string `json:"locale"`
}

type PaginationOptions

type PaginationOptions struct {
	Page     int
	PageSize int
}

type PriceDetail

type PriceDetail struct {
	Amount         float64 `json:"amount"`
	Currency       string  `json:"currency"`
	PriceString    string  `json:"price_string"`
	CurrencySymbol string  `json:"currency_symbol"`
}

type StreamURLs

type StreamURLs struct {
	Video []*Video `json:"Video"`
}

type User

type User struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	URL         string `json:"url"`
}

func GetUser added in v0.2.0

func GetUser() (*User, error)

type Video

type Video struct {
	Type  string `json:"type"`
	Label string `json:"label"`
	File  string `json:"file"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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