Documentation
¶
Overview ¶
Package javdb is the public Go SDK for the JavDB app JSON API.
Index ¶
- Constants
- func ActorPeriod(period string) string
- func FilterMagnets(magnets []map[string]any, cnsub, hd bool, minSize int) []map[string]any
- func LoadOrCreateDeviceUUID(path string) (string, error)
- func MagnetURI(m map[string]any) string
- func PickBestMagnet(magnets []map[string]any) map[string]any
- func RankingPeriod(period string) string
- type APIError
- type AuthRequired
- type AutoHostOptions
- type AutoHostResult
- type BrowseOptions
- type Client
- func (c *Client) API() *appapi.Client
- func (c *Client) AllEntityMovies(ctx context.Context, kind, entityID string, opt EntityMoviesOptions, ...) ([]map[string]any, error)
- func (c *Client) Browse(ctx context.Context, opt BrowseOptions) (SearchResult, error)
- func (c *Client) Collected(ctx context.Context, kind string) ([]map[string]any, error)
- func (c *Client) DownloadMovieMedia(ctx context.Context, movieID string, opt MovieMediaDownloadOptions) (MovieMediaDownloadResult, error)
- func (c *Client) EntityDetail(ctx context.Context, kind, id string) (map[string]any, error)
- func (c *Client) EntityMovies(ctx context.Context, kind, entityID string, opt EntityMoviesOptions) (SearchResult, error)
- func (c *Client) ListInfo(ctx context.Context, listID string) (map[string]any, error)
- func (c *Client) LoadOrRefreshTaxonomy(ctx context.Context, zone string, force bool) (*tags.Doc, string, error)
- func (c *Client) Login(ctx context.Context, username, password string) (string, error)
- func (c *Client) Mark(ctx context.Context, movieID, status string, score int, content string) (map[string]any, error)
- func (c *Client) MovieComments(ctx context.Context, movieID string, page, limit int) ([]map[string]any, error)
- func (c *Client) MovieDetail(ctx context.Context, movieID string) (map[string]any, error)
- func (c *Client) MovieMagnets(ctx context.Context, movieID string) ([]map[string]any, error)
- func (c *Client) MyLists(ctx context.Context, page, limit int, sortBy string) (SearchResult, error)
- func (c *Client) RankingsActors(ctx context.Context, period string) (SearchResult, error)
- func (c *Client) RankingsMovies(ctx context.Context, type_, period string) (SearchResult, error)
- func (c *Client) RankingsPlayback(ctx context.Context, filterBy, period string) (SearchResult, error)
- func (c *Client) RecentViewed(ctx context.Context) ([]map[string]any, error)
- func (c *Client) RefreshTagTaxonomy(ctx context.Context, zone string) (*tags.Doc, error)
- func (c *Client) RelatedLists(ctx context.Context, movieID string, page, limit int) (SearchResult, error)
- func (c *Client) ResolveEntity(ctx context.Context, kind, ref, zone string) (string, error)
- func (c *Client) ResolveMovieID(ctx context.Context, number string) (string, error)
- func (c *Client) ResolveTags(ctx context.Context, refs []string, zone string) ([]string, error)
- func (c *Client) ResolveUserID(ctx context.Context) (userID int64, username string, err error)
- func (c *Client) Search(ctx context.Context, keyword string, opt SearchOptions) (SearchResult, error)
- func (c *Client) SetToken(token string)
- func (c *Client) Token() string
- func (c *Client) Top250(ctx context.Context, zone, year string, startRank, page, limit int, ...) (SearchResult, error)
- func (c *Client) Unmark(ctx context.Context, movieID string) (bool, error)
- func (c *Client) WantMovies(ctx context.Context) ([]map[string]any, error)
- func (c *Client) WatchedMovies(ctx context.Context) ([]map[string]any, error)
- type EntityMoviesOptions
- type MovieMediaDownloadOptions
- type MovieMediaDownloadResult
- type Option
- type SearchOptions
- type SearchResult
Constants ¶
const ( HostMirror = settings.HostMirror HostMain = settings.HostMain )
Host constants.
Variables ¶
This section is empty.
Functions ¶
func ActorPeriod ¶
ActorPeriod is a deprecated alias for RankingPeriod. Deprecated: Use RankingPeriod instead.
func FilterMagnets ¶
Re-export magnet helpers for SDK callers.
func LoadOrCreateDeviceUUID ¶
LoadOrCreateDeviceUUID loads the stable device identifier at path or creates one when the file is absent. CLI callers use it before constructing a client; SDK callers may use it when they need the same identifier across processes.
func RankingPeriod ¶ added in v0.5.1
RankingPeriod re-export.
Types ¶
type AutoHostOptions ¶ added in v0.6.0
type AutoHostOptions struct {
PreferredHost string
Proxy string
DeviceUUID string
Timeout time.Duration // 每次 probe 请求的 timeout;零值沿用 transport 默认值。
Lang string
}
AutoHostOptions 配置显式自动线路选择。PreferredHost 是调用方提供的待验证候选 (通常来自上次选线的 route cache);SDK 不负责持久化。
type AutoHostResult ¶ added in v0.6.0
AutoHostResult 是自动选线结果。Latency 是缓存验证成功或全量测速赢家的单次 /startup 耗时。调用方用 javdb.New(WithHost(result.Host), ...) 构造业务客户端。
func SelectAutoHost ¶ added in v0.6.0
func SelectAutoHost(ctx context.Context, options AutoHostOptions) (AutoHostResult, error)
SelectAutoHost 通过真实 /startup 探测选择最快的 JavDB App API host。
它显式联网选线,返回具体 URL;不会让 javdb.New(WithHost("auto")) 自动联网。调用方应先 验证 route cache 中的 PreferredHost,成功后(ReusedPreferred==true)无需写入新结果; 重测选择时再把 result.Host 持久化。
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a concrete app-API client.
func (*Client) API ¶
API 为兼容旧调用方返回底层 adapter。该返回值不是稳定的外部 SDK 契约;新代码应优先使用 typed 方法。 Deprecated: use the documented Client methods instead.
func (*Client) AllEntityMovies ¶
func (c *Client) AllEntityMovies(ctx context.Context, kind, entityID string, opt EntityMoviesOptions, maxPages int) ([]map[string]any, error)
AllEntityMovies aggregates filmography pages.
func (*Client) Browse ¶
func (c *Client) Browse(ctx context.Context, opt BrowseOptions) (SearchResult, error)
Browse lists movies by category filters.
func (*Client) DownloadMovieMedia ¶
func (c *Client) DownloadMovieMedia(ctx context.Context, movieID string, opt MovieMediaDownloadOptions) (MovieMediaDownloadResult, error)
DownloadMovieMedia 下载调用方选择的影片媒体。图片会先验证并还原为标准图片字节; 预览视频会完整下载已结束的 HLS 预览流。输出文件不得预先存在。
func (*Client) EntityDetail ¶
EntityDetail fetches entity meta.
func (*Client) EntityMovies ¶
func (c *Client) EntityMovies(ctx context.Context, kind, entityID string, opt EntityMoviesOptions) (SearchResult, error)
EntityMovies lists filmography for an entity kind.
func (*Client) LoadOrRefreshTaxonomy ¶
func (c *Client) LoadOrRefreshTaxonomy(ctx context.Context, zone string, force bool) (*tags.Doc, string, error)
LoadOrRefreshTaxonomy loads disk taxonomy or refreshes.
func (*Client) Login ¶
Login authenticates and stores the token on the client. ctx is reserved for future cancellation; the underlying client is not yet context-aware.
func (*Client) Mark ¶
func (c *Client) Mark(ctx context.Context, movieID, status string, score int, content string) (map[string]any, error)
Mark marks a movie watched or want_watch.
func (*Client) MovieComments ¶
func (c *Client) MovieComments(ctx context.Context, movieID string, page, limit int) ([]map[string]any, error)
MovieComments returns one requested page from GET /api/v1/movies/{id}/reviews. It never follows later pages automatically.
func (*Client) MovieDetail ¶
MovieDetail returns GET /api/v4/movies/{id} nested movie map.
func (*Client) MovieMagnets ¶
MovieMagnets returns GET /api/v1/movies/{id}/magnets (works anonymously).
func (*Client) RankingsActors ¶
RankingsActors fetches actor rankings; period accepts day|week|month or daily|weekly|monthly.
func (*Client) RankingsMovies ¶
RankingsMovies fetches movie rankings.
func (*Client) RankingsPlayback ¶
func (c *Client) RankingsPlayback(ctx context.Context, filterBy, period string) (SearchResult, error)
RankingsPlayback fetches playback rankings.
func (*Client) RecentViewed ¶
RecentViewed returns recently viewed movies.
func (*Client) RefreshTagTaxonomy ¶
RefreshTagTaxonomy downloads EN+ZH taxonomies and saves tags-{zone}.json.
func (*Client) RelatedLists ¶
func (c *Client) RelatedLists(ctx context.Context, movieID string, page, limit int) (SearchResult, error)
RelatedLists returns public lists related to a movie.
func (*Client) ResolveEntity ¶
ResolveEntity resolves name/id to entity id.
func (*Client) ResolveMovieID ¶
ResolveMovieID maps a printed number to internal id (search zone=all).
func (*Client) ResolveTags ¶
ResolveTags maps free-form tag refs to ids.
func (*Client) ResolveUserID ¶
ResolveUserID returns the numeric user id (and optional display name) for the current token.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, keyword string, opt SearchOptions) (SearchResult, error)
Search runs GET /api/v2/search.
func (*Client) Top250 ¶
func (c *Client) Top250(ctx context.Context, zone, year string, startRank, page, limit int, ignoreWatched bool) (SearchResult, error)
Top250 fetches TOP250 (auth).
func (*Client) WantMovies ¶
WantMovies returns all want_watch (想看) movies.
type EntityMoviesOptions ¶
type EntityMoviesOptions = appapi.EntityMoviesOptions
EntityMoviesOptions re-export.
type MovieMediaDownloadOptions ¶
type MovieMediaDownloadOptions struct {
ThumbnailPath string
PreviewImagePath string
PreviewVideoPath string
}
MovieMediaDownloadOptions 指定要保存到本地的影片媒体。空路径表示不下载该媒体。 PreviewImagePath 始终只对应详情返回的第一张预览图。
type MovieMediaDownloadResult ¶
type MovieMediaDownloadResult struct {
ThumbnailPath string
ThumbnailBytes int64
PreviewImagePath string
PreviewImageBytes int64
PreviewVideoPath string
PreviewVideoBytes int64
}
MovieMediaDownloadResult 记录实际写入的媒体路径和字节数。
type Option ¶
type Option func(*options)
Option configures New.
func WithDeviceUUID ¶
WithDeviceUUID sets the app device_uuid public param.
type SearchOptions ¶
type SearchOptions = appapi.SearchOptions
SearchOptions is re-exported for SDK callers.