tiengtrungbotui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tiengtrungbotui is the library behind the tiengtrungbotui command line: the HTTP client, request shaping, and the typed data models for the Tiếng Trung Bỏ Túi Vietnamese Chinese-learning site.

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "tiengtrungbotui/dev (+https://github.com/tamnd/tiengtrungbotui-cli)"

DefaultUserAgent identifies the client to the remote host.

View Source
const Host = "www.tiengtrungbotui.com"

Host is the site this client talks to, and the host the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	Rate      time.Duration
	Retries   int
	// contains filtered or unexported fields
}

Client talks to tiengtrungbotui.com over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Episodes

func (c *Client) Episodes(ctx context.Context, seriesSlug string) ([]*Episode, error)

Episodes fetches a series page and returns all episodes from its JSON-LD data.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

func (*Client) Series

func (c *Client) Series(ctx context.Context) ([]*Series, error)

Series fetches the /videos index and returns all video series.

type Domain

type Domain struct{}

Domain is the tiengtrungbotui driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

func (Domain) Info

func (Domain) Info() kit.DomainInfo

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

func (Domain) Register

func (Domain) Register(app *kit.App)

type Episode

type Episode struct {
	Rank      int    `json:"rank"       csv:"rank"       tsv:"rank"`
	Series    string `json:"series"     csv:"series"     tsv:"series"`
	Level     string `json:"level"      csv:"level"      tsv:"level"`
	Title     string `json:"title"      csv:"title"      tsv:"title"`
	YouTubeID string `json:"youtube_id" csv:"youtube_id" tsv:"youtube_id"`
	URL       string `json:"url"        csv:"url"        tsv:"url"`
}

Episode is one video inside a series.

type Series

type Series struct {
	Rank  int    `json:"rank"  csv:"rank"  tsv:"rank"`
	Slug  string `json:"slug"  csv:"slug"  tsv:"slug"  kit:"id"`
	Title string `json:"title" csv:"title" tsv:"title"`
	URL   string `json:"url"   csv:"url"   tsv:"url"`
}

Series is one video playlist on tiengtrungbotui.com.

Jump to

Keyboard shortcuts

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