javdbapi

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 14 Imported by: 0

README

javdbapi

Installation

go get -u github.com/RPbro/javdbapi

Getting started

package main

import (
	"fmt"
	"net/http"
	"time"

	"github.com/RPbro/javdbapi"
)

func main() {
	client := javdbapi.NewClient(
		// optional
		javdbapi.WithDomain("https://javdb008.com"),
		// optional
		javdbapi.WithUserAgent("Mozilla/5.0 (Macintosh; ..."),
		// optional
		javdbapi.WithProxy("http://127.0.0.1:7890"),
		// optional
		javdbapi.WithTimeout(time.Second*30),
	)

	// optional: use other http.client
	c := &http.Client{}
	client.SetClient(c)

	// optional: filter
	filter := Filter{
		ScoreGT:        0,
		ScoreLT:        0,
		ScoreCountGT:   0,
		ScoreCountLT:   0,
		PubDateBefore:  time.Time{},
		PubDateAfter:   time.Time{},
		HasZH:          false,
		HasPreview:     false,
		ActressesIn:    nil,
		ActressesNotIn: nil,
		TagsIn:         nil,
		TagsNotIn:      nil,
		HasPics:        false,
		HasMagnets:     false,
		HasReviews:     false,
	}

	results, err := client.GetRaw().
		WithDetails().
		WithReviews().
		SetRaw("https://javdb.com/tags?c10=1,2,3,5").
		SetPage(1).
		SetLimit(10).
		SetFilter(filter).
		Get()
	if err != nil {
		panic(err)
	}

	for _, v := range results {
		fmt.Println(v)
	}
}
	// first
	_, err = client.GetFirst().
		WithReviews().
		SetRaw("https://javdb008.com/v/5EOxMY").
		First()
	if err != nil {
		panic(err)
	}
	// homepage
	_, err = client.GetHomes().
		SetCategoryCensored().
		SetFilterByCanDownload().
		SetSortByMagnetUpdate().
		Get()
	if err != nil {
		panic(err)
	}
	// actors
	_, err = client.GetActors().
		SetActor("M4Q7"). // M4Q7 is 明里つむぎ, see https://javdb.com/actors
		SetFilterHasZH().
		SetFilterPlayable().
		Get()
	if err != nil {
		panic(err)
	}
	// makers
	_, err = client.GetMakers().
		SetMaker("7R"). // 7R is S1 NO.1 STYLE, see https://javdb.com/makers
		SetFilterSingle().
		SetFilterHasPreview().
		Get()
	if err != nil {
		panic(err)
	}
	// rankings
	_, err = client.GetRankings().
		SetCategoryCensored().
		SetTimeMonthly().
		Get()
	if err != nil {
		panic(err)
	}
	// search
	_, err = client.GetSearch().
		SetQuery("PRED-483").
		Get()
	if err != nil {
		panic(err)
	}
type JavDB struct {
        req *request
        // basic
        Path       string    `json:"path"`
        Code       string    `json:"code"`
        Title      string    `json:"title"`
        Cover      string    `json:"cover"`
        Score      float64   `json:"score"`
        ScoreCount int       `json:"score_count"`
        PubDate    time.Time `json:"pub_date"`
        HasZH      bool      `json:"has_zh"`
        // WithDetails()
        Preview   string   `json:"preview"`
        Actresses []string `json:"actresses"`
        Tags      []string `json:"tags"`
        Pics      []string `json:"pics"`
        Magnets   []string `json:"magnets"`
        // WithReviews()
        Reviews []string `json:"reviews"`
}

Documentation

Index

Constants

View Source
const (
	ActorsFilterAll         = ""
	ActorsFilterPlayable    = "p"
	ActorsFilterSingle      = "s"
	ActorsFilterCanDownload = "d"
	ActorsFilterHasZH       = "c"
)
View Source
const (
	HomesCategoryAll         = ""
	HomesCategoryCensored    = "censored"
	HomesCategoryUncensored  = "uncensored"
	HomesCategoryWestern     = "western"
	HomesSortByPubDate       = "1"
	HomesSortByMagnetUpdate  = "2"
	HomesFilterByAll         = "0"
	HomesFilterByCanDownload = "1"
	HomesFilterByHasZH       = "2"
	HomesFilterByHasReviews  = "3"
)
View Source
const (
	MakersFilterAll         = ""
	MakersFilterPlayable    = "playable"
	MakersFilterSingle      = "single"
	MakersFilterCanDownload = "download"
	MakersFilterHasZH       = "cnsub"
	MakersFilterHasPreview  = "preview"
)
View Source
const (
	RankingsCategoryCensored   = "censored"
	RankingsCategoryUncensored = "uncensored"
	RankingsCategoryWestern    = "western"
	RankingsTimeDaily          = "daily"
	RankingsTimeWeekly         = "weekly"
	RankingsTimeMonthly        = "monthly"
)
View Source
const (
	PathReviews  = "/reviews/lastest"
	PathRankings = "/rankings/movies"
	PathMakers   = "/makers"
	PathActors   = "/actors"
	PathSearch   = "/search"
)

Variables

This section is empty.

Functions

func WithDomain

func WithDomain(domain string) func(c *Client)

func WithProxy

func WithProxy(addr string) func(c *Client)

func WithTimeout

func WithTimeout(timeout time.Duration) func(c *Client)

func WithUserAgent

func WithUserAgent(ua string) func(c *Client)

Types

type API

type API struct {
	Page   int
	Limit  int
	Filter Filter
	// contains filtered or unexported fields
}

func (*API) First

func (a *API) First(url string) (*JavDB, error)

func (*API) Get

func (a *API) Get(t interface{}) ([]*JavDB, error)

func (*API) SetFilter

func (a *API) SetFilter(filter Filter) *API

func (*API) SetLimit

func (a *API) SetLimit(limit int) *API

func (*API) SetPage

func (a *API) SetPage(page int) *API

func (*API) WithDebug

func (a *API) WithDebug() *API

func (*API) WithDetails

func (a *API) WithDetails() *API

func (*API) WithRandom

func (a *API) WithRandom() *API

func (*API) WithReviews

func (a *API) WithReviews() *API

type APIActors

type APIActors struct {
	Actor  string
	Filter []string
	// contains filtered or unexported fields
}

func (*APIActors) Get

func (a *APIActors) Get() ([]*JavDB, error)

func (*APIActors) SetActor

func (a *APIActors) SetActor(actor string) *APIActors

func (*APIActors) SetFilter

func (a *APIActors) SetFilter(filter Filter) *APIActors

func (*APIActors) SetFilterAll

func (a *APIActors) SetFilterAll() *APIActors

func (*APIActors) SetFilterCanDownload

func (a *APIActors) SetFilterCanDownload() *APIActors

func (*APIActors) SetFilterHasZH

func (a *APIActors) SetFilterHasZH() *APIActors

func (*APIActors) SetFilterPlayable

func (a *APIActors) SetFilterPlayable() *APIActors

func (*APIActors) SetFilterSingle

func (a *APIActors) SetFilterSingle() *APIActors

func (*APIActors) SetLimit

func (a *APIActors) SetLimit(limit int) *APIActors

func (*APIActors) SetPage

func (a *APIActors) SetPage(page int) *APIActors

func (*APIActors) WithDebug

func (a *APIActors) WithDebug() *APIActors

func (*APIActors) WithDetails

func (a *APIActors) WithDetails() *APIActors

func (*APIActors) WithRandom

func (a *APIActors) WithRandom() *APIActors

func (*APIActors) WithReviews

func (a *APIActors) WithReviews() *APIActors

type APIFirst

type APIFirst struct {
	Raw string
	// contains filtered or unexported fields
}

func (*APIFirst) First

func (a *APIFirst) First() (*JavDB, error)

func (*APIFirst) SetRaw

func (a *APIFirst) SetRaw(raw string) *APIFirst

func (*APIFirst) WithDebug

func (a *APIFirst) WithDebug() *APIFirst

func (*APIFirst) WithReviews

func (a *APIFirst) WithReviews() *APIFirst

type APIHomes

type APIHomes struct {
	Category string
	SortBy   string
	FilterBy string
	// contains filtered or unexported fields
}

func (*APIHomes) Get

func (a *APIHomes) Get() ([]*JavDB, error)

func (*APIHomes) SetCategoryAll

func (a *APIHomes) SetCategoryAll() *APIHomes

func (*APIHomes) SetCategoryCensored

func (a *APIHomes) SetCategoryCensored() *APIHomes

func (*APIHomes) SetCategoryUncensored

func (a *APIHomes) SetCategoryUncensored() *APIHomes

func (*APIHomes) SetCategoryWestern

func (a *APIHomes) SetCategoryWestern() *APIHomes

func (*APIHomes) SetFilter

func (a *APIHomes) SetFilter(filter Filter) *APIHomes

func (*APIHomes) SetFilterByAll

func (a *APIHomes) SetFilterByAll() *APIHomes

func (*APIHomes) SetFilterByCanDownload

func (a *APIHomes) SetFilterByCanDownload() *APIHomes

func (*APIHomes) SetFilterByHasReviews

func (a *APIHomes) SetFilterByHasReviews() *APIHomes

func (*APIHomes) SetFilterByHasZH

func (a *APIHomes) SetFilterByHasZH() *APIHomes

func (*APIHomes) SetLimit

func (a *APIHomes) SetLimit(limit int) *APIHomes

func (*APIHomes) SetPage

func (a *APIHomes) SetPage(page int) *APIHomes

func (*APIHomes) SetSortByMagnetUpdate

func (a *APIHomes) SetSortByMagnetUpdate() *APIHomes

func (*APIHomes) SetSortByPubDate

func (a *APIHomes) SetSortByPubDate() *APIHomes

func (*APIHomes) WithDebug

func (a *APIHomes) WithDebug() *APIHomes

func (*APIHomes) WithDetails

func (a *APIHomes) WithDetails() *APIHomes

func (*APIHomes) WithRandom

func (a *APIHomes) WithRandom() *APIHomes

func (*APIHomes) WithReviews

func (a *APIHomes) WithReviews() *APIHomes

type APIMakers

type APIMakers struct {
	Maker  string
	Filter string
	// contains filtered or unexported fields
}

func (*APIMakers) Get

func (a *APIMakers) Get() ([]*JavDB, error)

func (*APIMakers) SetFilter

func (a *APIMakers) SetFilter(filter Filter) *APIMakers

func (*APIMakers) SetFilterAll

func (a *APIMakers) SetFilterAll() *APIMakers

func (*APIMakers) SetFilterCanDownload

func (a *APIMakers) SetFilterCanDownload() *APIMakers

func (*APIMakers) SetFilterHasPreview

func (a *APIMakers) SetFilterHasPreview() *APIMakers

func (*APIMakers) SetFilterHasZH

func (a *APIMakers) SetFilterHasZH() *APIMakers

func (*APIMakers) SetFilterPlayable

func (a *APIMakers) SetFilterPlayable() *APIMakers

func (*APIMakers) SetFilterSingle

func (a *APIMakers) SetFilterSingle() *APIMakers

func (*APIMakers) SetLimit

func (a *APIMakers) SetLimit(limit int) *APIMakers

func (*APIMakers) SetMaker

func (a *APIMakers) SetMaker(maker string) *APIMakers

func (*APIMakers) SetPage

func (a *APIMakers) SetPage(page int) *APIMakers

func (*APIMakers) WithDebug

func (a *APIMakers) WithDebug() *APIMakers

func (*APIMakers) WithDetails

func (a *APIMakers) WithDetails() *APIMakers

func (*APIMakers) WithRandom

func (a *APIMakers) WithRandom() *APIMakers

func (*APIMakers) WithReviews

func (a *APIMakers) WithReviews() *APIMakers

type APIRankings

type APIRankings struct {
	Category string
	Time     string
	// contains filtered or unexported fields
}

func (*APIRankings) Get

func (a *APIRankings) Get() ([]*JavDB, error)

func (*APIRankings) SetCategoryCensored

func (a *APIRankings) SetCategoryCensored() *APIRankings

func (*APIRankings) SetCategoryUncensored

func (a *APIRankings) SetCategoryUncensored() *APIRankings

func (*APIRankings) SetCategoryWestern

func (a *APIRankings) SetCategoryWestern() *APIRankings

func (*APIRankings) SetFilter

func (a *APIRankings) SetFilter(filter Filter) *APIRankings

func (*APIRankings) SetLimit

func (a *APIRankings) SetLimit(limit int) *APIRankings

func (*APIRankings) SetPage

func (a *APIRankings) SetPage(page int) *APIRankings

func (*APIRankings) SetTimeDaily

func (a *APIRankings) SetTimeDaily() *APIRankings

func (*APIRankings) SetTimeMonthly

func (a *APIRankings) SetTimeMonthly() *APIRankings

func (*APIRankings) SetTimeWeekly

func (a *APIRankings) SetTimeWeekly() *APIRankings

func (*APIRankings) WithDebug

func (a *APIRankings) WithDebug() *APIRankings

func (*APIRankings) WithDetails

func (a *APIRankings) WithDetails() *APIRankings

func (*APIRankings) WithRandom

func (a *APIRankings) WithRandom() *APIRankings

func (*APIRankings) WithReviews

func (a *APIRankings) WithReviews() *APIRankings

type APIRaw

type APIRaw struct {
	Raw string
	// contains filtered or unexported fields
}

func (*APIRaw) Get

func (a *APIRaw) Get() ([]*JavDB, error)

func (*APIRaw) SetFilter

func (a *APIRaw) SetFilter(filter Filter) *APIRaw

func (*APIRaw) SetLimit

func (a *APIRaw) SetLimit(limit int) *APIRaw

func (*APIRaw) SetPage

func (a *APIRaw) SetPage(page int) *APIRaw

func (*APIRaw) SetRaw

func (a *APIRaw) SetRaw(raw string) *APIRaw

func (*APIRaw) WithDebug

func (a *APIRaw) WithDebug() *APIRaw

func (*APIRaw) WithDetails

func (a *APIRaw) WithDetails() *APIRaw

func (*APIRaw) WithRandom

func (a *APIRaw) WithRandom() *APIRaw

func (*APIRaw) WithReviews

func (a *APIRaw) WithReviews() *APIRaw

type APISearch

type APISearch struct {
	Query string
	// contains filtered or unexported fields
}

func (*APISearch) Get

func (a *APISearch) Get() ([]*JavDB, error)

func (*APISearch) SetFilter

func (a *APISearch) SetFilter(filter Filter) *APISearch

func (*APISearch) SetLimit

func (a *APISearch) SetLimit(limit int) *APISearch

func (*APISearch) SetPage

func (a *APISearch) SetPage(page int) *APISearch

func (*APISearch) SetQuery

func (a *APISearch) SetQuery(query string) *APISearch

func (*APISearch) WithDebug

func (a *APISearch) WithDebug() *APISearch

func (*APISearch) WithDetails

func (a *APISearch) WithDetails() *APISearch

func (*APISearch) WithReviews

func (a *APISearch) WithReviews() *APISearch

type Client

type Client struct {
	Domain    string
	UserAgent string
	ProxyAddr string
	HTTP      *http.Client
}

func NewClient

func NewClient(options ...option) *Client

func (*Client) GetActors

func (c *Client) GetActors() *APIActors

func (*Client) GetFirst

func (c *Client) GetFirst() *APIFirst

func (*Client) GetHomes

func (c *Client) GetHomes() *APIHomes

func (*Client) GetMakers

func (c *Client) GetMakers() *APIMakers

func (*Client) GetRankings

func (c *Client) GetRankings() *APIRankings

func (*Client) GetRaw

func (c *Client) GetRaw() *APIRaw

func (*Client) GetSearch

func (c *Client) GetSearch() *APISearch

func (*Client) SetClient

func (c *Client) SetClient(client *http.Client) *Client

type Filter

type Filter struct {
	ScoreGT        float64
	ScoreLT        float64
	ScoreCountGT   int
	ScoreCountLT   int
	PubDateBefore  time.Time
	PubDateAfter   time.Time
	HasZH          bool
	HasPreview     bool
	ActressesIn    []string
	ActressesNotIn []string
	TagsIn         []string
	TagsNotIn      []string
	HasPics        bool
	HasMagnets     bool
	HasReviews     bool
}

type JavDB

type JavDB struct {
	Path       string    `json:"path"`
	Code       string    `json:"code"`
	Title      string    `json:"title"`
	Cover      string    `json:"cover"`
	Score      float64   `json:"score"`
	ScoreCount int       `json:"score_count"`
	PubDate    time.Time `json:"pub_date"`
	HasZH      bool      `json:"has_zh"`

	Preview   string   `json:"preview"`
	Actresses []string `json:"actresses"`
	Tags      []string `json:"tags"`
	Pics      []string `json:"pics"`
	Magnets   []string `json:"magnets"`

	Reviews []string `json:"reviews"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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