Documentation
¶
Overview ¶
Package appapi is the signed JavDB app JSON API client.
Index ¶
- Constants
- Variables
- func ActorPeriod(period string) string
- func AllPages(fetch func(page int) ([]map[string]any, error), maxPages int) ([]map[string]any, error)
- func BuildEntityFilter(kind, entityID, zone string, main []string) (string, error)
- func BuildSearchParams(keyword string, opt SearchOptions) map[string]string
- func BuildTagFilter(zone string, main, tags []string, year, month string) (string, error)
- func BuildTop250Params(zone, year string, startRank, page, limit int, ignoreWatched bool) (map[string]string, error)
- 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
- func ResolveNumber(movies []map[string]any, number string) (string, error)
- func SearchTypeListKey(kind string) string
- type AuthRequired
- type BrowseOptions
- type Client
- func (c *Client) AllEntityMovies(kind, entityID string, opt EntityMoviesOptions, maxPages int) ([]map[string]any, error)
- func (c *Client) Browse(opt BrowseOptions) (SearchResult, error)
- func (c *Client) Collected(kind string) ([]map[string]any, error)
- func (c *Client) CollectedPage(kind string, page int) ([]map[string]any, error)
- func (c *Client) DeleteJSON(path string, params map[string]string, dest any) error
- func (c *Client) DeviceUUID() string
- func (c *Client) DownloadHLS(playlistURL, target string) (int64, error)
- func (c *Client) DownloadImage(sourceURL, target string) (int64, error)
- func (c *Client) EntityDetail(kind, id string) (map[string]any, error)
- func (c *Client) EntityMovies(kind, entityID string, opt EntityMoviesOptions) (SearchResult, error)
- func (c *Client) GetJSON(path string, params map[string]string, dest any) error
- func (c *Client) ListInfo(listID string) (map[string]any, error)
- func (c *Client) LoadOrRefreshTaxonomy(zone string, force bool) (*tags.Doc, string, error)
- func (c *Client) Login(username, password string) (string, error)
- func (c *Client) Mark(movieID, status string, score int, content string) (map[string]any, error)
- func (c *Client) MovieComments(movieID string, page, limit int) ([]map[string]any, error)
- func (c *Client) MovieDetail(movieID string) (map[string]any, error)
- func (c *Client) MovieMagnets(movieID string) ([]map[string]any, error)
- func (c *Client) MyLists(page, limit int, sortBy string) (SearchResult, error)
- func (c *Client) PostFormJSON(path string, form map[string]string, dest any) error
- func (c *Client) RankingsActors(period string) (SearchResult, error)
- func (c *Client) RankingsMovies(type_, period string) (SearchResult, error)
- func (c *Client) RankingsPlayback(filterBy, period string) (SearchResult, error)
- func (c *Client) RecentViewed() ([]map[string]any, error)
- func (c *Client) RefreshTagTaxonomy(zone string) (*tags.Doc, error)
- func (c *Client) RelatedLists(movieID string, page, limit int) (SearchResult, error)
- func (c *Client) ResolveEntity(kind, ref, zone string) (string, error)
- func (c *Client) ResolveMovieID(number string) (string, error)
- func (c *Client) ResolveTags(refs []string, zone string) ([]string, error)
- func (c *Client) ResolveUserID(token string) (int64, string, error)
- func (c *Client) ReviewMoviesPage(status string, page int) ([]map[string]any, error)
- func (c *Client) Search(keyword string, opt SearchOptions) (SearchResult, error)
- func (c *Client) SetToken(token string)
- func (c *Client) Startup() (map[string]json.RawMessage, error)
- func (c *Client) TagsRaw(zone, lang string) ([]map[string]any, error)
- func (c *Client) Token() string
- func (c *Client) Top250(zone, year string, startRank, page, limit int, ignoreWatched bool) (SearchResult, error)
- func (c *Client) Unmark(movieID string) (bool, error)
- func (c *Client) Users() (map[string]json.RawMessage, error)
- func (c *Client) WantMovies() ([]map[string]any, error)
- func (c *Client) WatchedMovies() ([]map[string]any, error)
- type EntityMoviesOptions
- type Error
- type LoginResponse
- type Options
- type SearchOptions
- type SearchResult
Constants ¶
const ( AppVersion = "1.9.28" AppVersionNumber = "10928" UserAgent = "Dart/3.4 (dart:io)" HostMirror = "https://jdforrepam.com" HostMain = "https://javdb.com" )
Variables ¶
var CollectionSpecs = map[string]struct { Path string Key string }{ "actors": {"/api/v1/users/collected_actors", "actors"}, "series": {"/api/v1/users/collected_series", "series"}, "codes": {"/api/v1/users/collected_codes", "codes"}, "makers": {"/api/v1/users/collected_makers", "makers"}, "directors": {"/api/v1/users/collected_directors", "directors"}, }
CollectionSpecs maps collection kind → (path, response list key). collected_lists is intentionally omitted (server 500).
var EntityLetters = map[string]string{
"actor": "a",
"series": "s",
"maker": "m",
"director": "d",
"code": "c",
"list": "l",
}
EntityLetters maps entity kind → filter_by letter.
var MainFlags = map[string]bool{ "p": true, "m": true, "c": true, "s": true, "i": true, "v": true, }
MainFlags are valid main-attribute letters in filter_by masks.
var Zones = map[string]int{
"censored": 0,
"uncensored": 1,
"western": 2,
"fc2": 3,
}
Zone digit for movie_type / filter_by masks.
Functions ¶
func ActorPeriod ¶
ActorPeriod maps CLI day/week/month → API daily/weekly/monthly for actor rankings. Deprecated: Use RankingPeriod instead.
func AllPages ¶
func AllPages(fetch func(page int) ([]map[string]any, error), maxPages int) ([]map[string]any, error)
AllPages aggregates pages until empty, de-duplicating by id.
func BuildEntityFilter ¶
BuildEntityFilter builds filter_by for entity filmography. {zone}:{letter}:{id} or {zone}:{letter}:{id}:{main}::
func BuildSearchParams ¶
func BuildSearchParams(keyword string, opt SearchOptions) map[string]string
BuildSearchParams returns query params for /api/v2/search (public params merged by Client).
func BuildTagFilter ¶
BuildTagFilter builds filter_by for category browse: {zone}:t:{main}:{tags}:{year}:{month}:
func BuildTop250Params ¶
func BuildTop250Params(zone, year string, startRank, page, limit int, ignoreWatched bool) (map[string]string, error)
BuildTop250Params builds query for GET /api/v1/movies/top. year wins over zone when both set. Empty both → type=all.
func FilterMagnets ¶
FilterMagnets applies client-side cnsub/hd/min_size filters.
func LoadOrCreateDeviceUUID ¶
LoadOrCreateDeviceUUID returns a stable device uuid from path, creating if missing.
func PickBestMagnet ¶
PickBestMagnet prefers cnsub, then hd, then larger size, then files_count.
func RankingPeriod ¶ added in v0.5.1
RankingPeriod maps CLI day/week/month → API daily/weekly/monthly for rankings.
func ResolveNumber ¶
ResolveNumber finds the internal movie id for a printed number (e.g. SSIS-589). Prefers an exact case-insensitive number match; else first search hit. Uses zone "all" (omit movie_type) so uncensored/western/fc2 still resolve.
func SearchTypeListKey ¶
SearchTypeListKey maps entity kind to search response list key.
Types ¶
type AuthRequired ¶
type AuthRequired struct {
API Error
}
AuthRequired means the caller should re-login.
func (*AuthRequired) Error ¶
func (e *AuthRequired) Error() string
func (*AuthRequired) Unwrap ¶
func (e *AuthRequired) Unwrap() error
type BrowseOptions ¶
type BrowseOptions struct {
Zone string
Main []string
TagIDs []string // already resolved ids
Year string
Month string
Sort string
Order string
Page int
Limit int
}
BrowseOptions for GET /api/v1/movies/tags category page.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to /api/v1..v4 with jdsignature.
func (*Client) AllEntityMovies ¶
func (c *Client) AllEntityMovies(kind, entityID string, opt EntityMoviesOptions, maxPages int) ([]map[string]any, error)
AllEntityMovies pages until empty (cap maxPages).
func (*Client) Browse ¶
func (c *Client) Browse(opt BrowseOptions) (SearchResult, error)
Browse lists movies by tag filter mask.
func (*Client) CollectedPage ¶
CollectedPage is one page of a user collection kind.
func (*Client) DeleteJSON ¶
DeleteJSON performs a signed DELETE.
func (*Client) DeviceUUID ¶
DeviceUUID returns the device id used in public params.
func (*Client) DownloadHLS ¶ added in v0.4.0
DownloadHLS 下载一个已结束的 HLS 媒体播放列表,并将解密后的媒体分片串接到 target。
func (*Client) DownloadImage ¶ added in v0.4.0
DownloadImage 下载并还原图片 CDN 返回的图片数据,再以新文件方式写入 target。
func (*Client) EntityDetail ¶
EntityDetail fetches GET /api/v1/{kind}s/{id} (or lists/{id} for list).
func (*Client) EntityMovies ¶
func (c *Client) EntityMovies(kind, entityID string, opt EntityMoviesOptions) (SearchResult, error)
EntityMovies lists movies for an entity via GET /api/v1/movies/tags.
func (*Client) LoadOrRefreshTaxonomy ¶
LoadOrRefreshTaxonomy returns disk doc or refreshes.
func (*Client) Login ¶
Login posts username/password and stores the bearer token on the client. Returns the token string. Does not resolve user id by itself.
func (*Client) MovieComments ¶ added in v0.4.0
MovieComments 获取影片评论的一页数据。它只请求调用方指定的一页,绝不自动追取后续页。
func (*Client) MovieDetail ¶
MovieDetail returns the nested movie object from GET /api/v4/movies/{id}.
func (*Client) MovieMagnets ¶
MovieMagnets returns magnets for an internal id (GET /api/v1/movies/{id}/magnets). Works without a bearer token; the token (when set) is forwarded as-is.
func (*Client) MyLists ¶
func (c *Client) MyLists(page, limit int, sortBy string) (SearchResult, error)
MyLists GET /api/v1/lists — sort_by is required by the server.
func (*Client) PostFormJSON ¶
PostFormJSON performs a signed POST form and unmarshals data.
func (*Client) RankingsActors ¶
func (c *Client) RankingsActors(period string) (SearchResult, error)
RankingsActors GET /api/v1/rankings/actors — period accepts day|week|month or daily|weekly|monthly.
func (*Client) RankingsMovies ¶
func (c *Client) RankingsMovies(type_, period string) (SearchResult, error)
RankingsMovies GET /api/v1/rankings
func (*Client) RankingsPlayback ¶
func (c *Client) RankingsPlayback(filterBy, period string) (SearchResult, error)
RankingsPlayback GET /api/v1/rankings/playback
func (*Client) RecentViewed ¶
RecentViewed returns GET /api/v1/users/recent_viewed movies (unpaged).
func (*Client) RefreshTagTaxonomy ¶
RefreshTagTaxonomy fetches EN+ZH and writes tags-{zone}.json.
func (*Client) RelatedLists ¶
func (c *Client) RelatedLists(movieID string, page, limit int) (SearchResult, error)
RelatedLists GET /api/v1/lists/related?movie_id=
func (*Client) ResolveEntity ¶
ResolveEntity resolves id or name to entity id.
func (*Client) ResolveMovieID ¶
ResolveMovieID searches with zone=all and resolves number → id.
func (*Client) ResolveTags ¶
ResolveTags maps free-form refs to ids for a zone.
func (*Client) ResolveUserID ¶
ResolveUserID tries JWT claims, then /users, then /startup.user.
func (*Client) ReviewMoviesPage ¶
ReviewMoviesPage is one page of GET /api/v2/users/review_movies.
func (*Client) Search ¶
func (c *Client) Search(keyword string, opt SearchOptions) (SearchResult, error)
Search calls GET /api/v2/search.
func (*Client) Startup ¶
func (c *Client) Startup() (map[string]json.RawMessage, error)
Startup returns GET /api/v1/startup data.
func (*Client) TagsRaw ¶
TagsRaw fetches GET /api/v2/tags?type={zone digit} categories list under "tags".
func (*Client) Top250 ¶
func (c *Client) Top250(zone, year string, startRank, page, limit int, ignoreWatched bool) (SearchResult, error)
Top250 GET /api/v1/movies/top (auth required).
func (*Client) Users ¶
func (c *Client) Users() (map[string]json.RawMessage, error)
Users returns GET /api/v1/users data (profile).
func (*Client) WantMovies ¶
WantMovies returns all want_watch (想看) movies.
type EntityMoviesOptions ¶
type EntityMoviesOptions struct {
Zone string
Page int
Limit int
Sort string
Order string
Main []string
Tags []string // resolved tag ids
}
EntityMoviesOptions for filmography listing.
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
AccessToken string `json:"access_token"`
User json.RawMessage `json:"user"`
// catch-all for probing
Raw map[string]json.RawMessage `json:"-"`
}
LoginResponse is the data payload of POST /api/v1/sessions.
type Options ¶
type Options struct {
Host string // full base URL
Token string
DeviceUUID string
Proxy string
Timeout time.Duration
Lang string
// Device profile (optional overrides)
AppChannel string
SystemVersion string
DeviceModel string
DeviceName string
}
Options for New.
type SearchOptions ¶
type SearchOptions struct {
Page int
Limit int // 0 = omit
Zone string
Sort string // movie_sort_by
FilterBy string // movie_filter_by
Type string // result dimension
}
SearchOptions configures GET /api/v2/search.
Zone: "censored", "uncensored", "western", "fc2", or "all"/"" to omit movie_type.
type SearchResult ¶
type SearchResult map[string]json.RawMessage
SearchResult is a loosely typed /api/v2/search data payload. Keys present depend on Type (movies/codes/series/actors/makers/directors/lists).
func (SearchResult) Movies ¶
func (r SearchResult) Movies() []map[string]any
Movies unmarshals the movies array if present.