appapi

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package appapi is the signed JavDB app JSON API client.

Index

Constants

View Source
const (
	AppVersion       = "1.9.28"
	AppVersionNumber = "10928"
	UserAgent        = "Dart/3.4 (dart:io)"

	HostMirror = "https://jdforrepam.com"
	HostMain   = "https://javdb.com"
)

Variables

View Source
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).

View Source
var EntityLetters = map[string]string{
	"actor":    "a",
	"series":   "s",
	"maker":    "m",
	"director": "d",
	"code":     "c",
	"list":     "l",
}

EntityLetters maps entity kind → filter_by letter.

View Source
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.

View Source
var Zones = map[string]int{
	"censored":   0,
	"uncensored": 1,
	"western":    2,
	"fc2":        3,
}

Zone digit for movie_type / filter_by masks.

Functions

func ActorPeriod

func ActorPeriod(period string) string

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

func BuildEntityFilter(kind, entityID, zone string, main []string) (string, error)

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

func BuildTagFilter(zone string, main, tags []string, year, month string) (string, error)

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

func FilterMagnets(magnets []map[string]any, cnsub, hd bool, minSize int) []map[string]any

FilterMagnets applies client-side cnsub/hd/min_size filters.

func LoadOrCreateDeviceUUID

func LoadOrCreateDeviceUUID(path string) (string, error)

LoadOrCreateDeviceUUID returns a stable device uuid from path, creating if missing.

func MagnetURI

func MagnetURI(m map[string]any) string

MagnetURI builds magnet:?xt=urn:btih:… from a row.

func PickBestMagnet

func PickBestMagnet(magnets []map[string]any) map[string]any

PickBestMagnet prefers cnsub, then hd, then larger size, then files_count.

func RankingPeriod added in v0.5.1

func RankingPeriod(period string) string

RankingPeriod maps CLI day/week/month → API daily/weekly/monthly for rankings.

func ResolveNumber

func ResolveNumber(movies []map[string]any, number string) (string, error)

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

func SearchTypeListKey(kind string) string

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 New

func New(opts Options) (*Client, error)

New constructs a signed API client.

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) Collected

func (c *Client) Collected(kind string) ([]map[string]any, error)

Collected aggregates all pages of a collection kind.

func (*Client) CollectedPage

func (c *Client) CollectedPage(kind string, page int) ([]map[string]any, error)

CollectedPage is one page of a user collection kind.

func (*Client) DeleteJSON

func (c *Client) DeleteJSON(path string, params map[string]string, dest any) error

DeleteJSON performs a signed DELETE.

func (*Client) DeviceUUID

func (c *Client) DeviceUUID() string

DeviceUUID returns the device id used in public params.

func (*Client) DownloadHLS added in v0.4.0

func (c *Client) DownloadHLS(playlistURL, target string) (int64, error)

DownloadHLS 下载一个已结束的 HLS 媒体播放列表,并将解密后的媒体分片串接到 target。

func (*Client) DownloadImage added in v0.4.0

func (c *Client) DownloadImage(sourceURL, target string) (int64, error)

DownloadImage 下载并还原图片 CDN 返回的图片数据,再以新文件方式写入 target。

func (*Client) EntityDetail

func (c *Client) EntityDetail(kind, id string) (map[string]any, error)

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) GetJSON

func (c *Client) GetJSON(path string, params map[string]string, dest any) error

GetJSON performs a signed GET and unmarshals data into dest (optional).

func (*Client) ListInfo

func (c *Client) ListInfo(listID string) (map[string]any, error)

ListInfo GET /api/v1/lists/{id} — full payload (list, is_creator, …).

func (*Client) LoadOrRefreshTaxonomy

func (c *Client) LoadOrRefreshTaxonomy(zone string, force bool) (*tags.Doc, string, error)

LoadOrRefreshTaxonomy returns disk doc or refreshes.

func (*Client) Login

func (c *Client) Login(username, password string) (string, error)

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) Mark

func (c *Client) Mark(movieID, status string, score int, content string) (map[string]any, error)

Mark posts POST /api/v1/movies/{id}/reviews. status ∈ watched|want_watch.

func (*Client) MovieComments added in v0.4.0

func (c *Client) MovieComments(movieID string, page, limit int) ([]map[string]any, error)

MovieComments 获取影片评论的一页数据。它只请求调用方指定的一页,绝不自动追取后续页。

func (*Client) MovieDetail

func (c *Client) MovieDetail(movieID string) (map[string]any, error)

MovieDetail returns the nested movie object from GET /api/v4/movies/{id}.

func (*Client) MovieMagnets

func (c *Client) MovieMagnets(movieID string) ([]map[string]any, error)

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

func (c *Client) PostFormJSON(path string, form map[string]string, dest any) error

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

func (c *Client) RecentViewed() ([]map[string]any, error)

RecentViewed returns GET /api/v1/users/recent_viewed movies (unpaged).

func (*Client) RefreshTagTaxonomy

func (c *Client) RefreshTagTaxonomy(zone string) (*tags.Doc, error)

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

func (c *Client) ResolveEntity(kind, ref, zone string) (string, error)

ResolveEntity resolves id or name to entity id.

func (*Client) ResolveMovieID

func (c *Client) ResolveMovieID(number string) (string, error)

ResolveMovieID searches with zone=all and resolves number → id.

func (*Client) ResolveTags

func (c *Client) ResolveTags(refs []string, zone string) ([]string, error)

ResolveTags maps free-form refs to ids for a zone.

func (*Client) ResolveUserID

func (c *Client) ResolveUserID(token string) (int64, string, error)

ResolveUserID tries JWT claims, then /users, then /startup.user.

func (*Client) ReviewMoviesPage

func (c *Client) ReviewMoviesPage(status string, page int) ([]map[string]any, error)

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) SetToken

func (c *Client) SetToken(token string)

SetToken updates the bearer token.

func (*Client) Startup

func (c *Client) Startup() (map[string]json.RawMessage, error)

Startup returns GET /api/v1/startup data.

func (*Client) TagsRaw

func (c *Client) TagsRaw(zone, lang string) ([]map[string]any, error)

TagsRaw fetches GET /api/v2/tags?type={zone digit} categories list under "tags".

func (*Client) Token

func (c *Client) Token() string

Token returns the current bearer token.

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) Unmark

func (c *Client) Unmark(movieID string) (bool, error)

Unmark deletes the user's review for a movie. Returns false if none.

func (*Client) Users

func (c *Client) Users() (map[string]json.RawMessage, error)

Users returns GET /api/v1/users data (profile).

func (*Client) WantMovies

func (c *Client) WantMovies() ([]map[string]any, error)

WantMovies returns all want_watch (想看) movies.

func (*Client) WatchedMovies

func (c *Client) WatchedMovies() ([]map[string]any, error)

WatchedMovies returns all watched (看過) 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 Error

type Error struct {
	Action  string
	Message string
}

Error is a server-side API failure (success:0).

func (*Error) Error

func (e *Error) Error() string

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.

func (SearchResult) Named

func (r SearchResult) Named(key string) []map[string]any

Named unmarshals a named dimension list (codes, series, actors, …).

Jump to

Keyboard shortcuts

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