PicaComic

package module
v0.0.0-...-25d20c8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_URL             = "https://picaapi.picacomic.com"
	API_AUTH_SIGNIN     = "/auth/sign-in"
	API_COMICS_SEARCH   = "/comics/advanced-search"
	API_COMICS          = "/comics"
	API_KEYWORDS        = "/keywords"        // 紳士都在搜的關鍵字
	API_CATEGORIES      = "/categories"      // 熱門分類
	API_USERS_FAVOURITE = "/users/favourite" // 已收藏

	IMG_STATIC = "/static"
)

Variables

View Source
var (
	OrdersList = map[string]string{
		"ua": "默认",
		"dd": "新到舊",
		"da": "舊到新",
		"ld": "最多愛心",
		"vd": "最多紳士指名",
	}
	CategoriesList = []string{
		"嗶咔漢化",
		"全彩",
		"長篇",
		"同人",
		"短篇",
		"圓神領域",
		"碧藍幻想",

		"CG雜圖",
		"英語 ENG",
		"生肉",

		"純愛",
		"百合花園",
		"耽美花園",
		"偽娘哲學",
		"後宮閃光",
		"扶他樂園",

		"姐姐系",
		"妹妹系",

		"SM",
		"性轉換",
		"足の恋",
		"人妻",
		"NTR",
		"強暴",
		"非人類",

		"艦隊收藏",
		"Love Live",
		"SAO 刀劍神域",
		"Fate",
		"東方",

		"WEBTOON",
		"禁書目錄",
		"歐美",
		"Cosplay",
		"重口地帶",
	}
)

Functions

func DoApi

func DoApi(ctx context.Context, method string, url string, body any) (*http.Response, []byte, error)

func DownloadCoversIter

func DownloadCoversIter(ctx context.Context, search *SearchResp) iter.Seq2[Image, error]

func DownloadPagesIter

func DownloadPagesIter(ctx context.Context, pages *PagesResp) iter.Seq2[Image, error]

func SetThreads

func SetThreads(n int)

SetThreads 设置下载并发数

func SetToken

func SetToken(token string)

func SetUseEnvProxy

func SetUseEnvProxy(b bool)

SetUseEnvProxy 设置是否使用系统环境变量中的代理

默认为 true

Types

type BaseResp

type BaseResp struct {
	Code    int            `json:"code"`
	Message string         `json:"message"`
	Data    map[string]any `json:"data"` // delay decode using [mapstructure.Decode]
}

type CategoriesResp

type CategoriesResp struct {
	Categories []struct {
		CategoryBase
		CategoryLink
		CategoryTag
	}
}

func Categories

func Categories(ctx context.Context) (*CategoriesResp, error)

Categories 熱門分類

type CategoryBase

type CategoryBase struct {
	Title string    `json:"title"`
	Thumb ImageInfo `json:"thumb"`
}
type CategoryLink struct {
	Link   string `json:"link"` // "" if !.IsWeb
	IsWeb  bool   `json:"isWeb"`
	Active bool   `json:"active"` // always true
}

type CategoryTag

type CategoryTag struct {
	Id          string `json:"_id"`
	Description string `json:"description"`
}

type Comic

type Comic struct {
	UnderlineId string    `json:"_id"` // == .Id
	Title       string    `json:"title"`
	Author      string    `json:"author"`
	TotalViews  int       `json:"totalViews"`
	TotalLikes  int       `json:"totalLikes"`
	PagesCount  int       `json:"pagesCount"`
	EpsCount    int       `json:"epsCount"`
	Finished    bool      `json:"finished"`
	Categories  []string  `json:"categories"`
	Tags        []string  `json:"tags"`
	Thumb       ImageInfo `json:"thumb"`
	Id          string    `json:"id"`
	LikesCount  int       `json:"likesCount"`
}

type ComicInfoResp

type ComicInfoResp struct {
	Comic DetailComic `json:"comic"`
}

func ComicInfo

func ComicInfo(ctx context.Context, bookId string) (*ComicInfoResp, error)

type ComicsResp

type ComicsResp struct {
	Comics struct {
		Docs  []Comic `json:"docs"`
		Stats `json:",squash"`
	} `json:"comics"`
}

func Comics

func Comics(ctx context.Context, block, tag string, sort Sort, page uint) (*ComicsResp, error)

type CommentDoc

type CommentDoc struct {
	UnderlineId   string `json:"_id"`
	Content       string `json:"content"`
	User          User   `json:"_user"`
	Id            string `json:"id"`
	LikesCount    int    `json:"likes_count"`
	CommentsCount int    `json:"comments_count"`
	IsLiked       bool   `json:"is_liked"`
}

type CommentsResp

type CommentsResp struct {
	Comments struct {
		Docs  []CommentDoc `json:"docs"`
		Stats `json:",squash"`
	} `json:"comments"`
}

func Comments

func Comments(ctx context.Context, bookId string, page int) (*CommentsResp, error)

Comments 偉論, page 可为 -1

type DetailComic

type DetailComic struct {
	Id      string `json:"_id"`
	Creator User   `json:"creator"`

	Title       string    `json:"title"`
	Description string    `json:"description"`
	Thumb       ImageInfo `json:"thumb"`
	Author      string    `json:"author"`
	ChineseTeam string    `json:"chineseTeam"`
	Categories  []string  `json:"categories"`
	Tags        []string  `json:"tags"`
	PagesCount  int       `json:"pagesCount"`
	EpsCount    int       `json:"epsCount"`
	Finished    bool      `json:"finished"`

	UpdatedAt string `json:"updated_at"` // "2025-11-01T17:30:24.731Z"
	CreatedAt string `json:"created_at"` // "2025-05-19T11:34:55.755Z"

	AllowDownload bool `json:"allowDownload"`
	AllowComment  bool `json:"allowComment"`

	TotalLikes    int `json:"totalLikes"`
	TotalViews    int `json:"totalViews"`
	TotalComments int `json:"totalComments"`
	ViewsCount    int `json:"viewsCount"`
	LikesCount    int `json:"likesCount"`
	CommentsCount int `json:"commentsCount"`

	IsFavourite bool `json:"isFavourite"`
	IsLiked     bool `json:"isLiked"`
}

type Episode

type Episode struct {
	UnderlineId string `json:"_id"`
	Title       string `json:"title"`
	Order       int    `json:"order"`      // Docs 中从大到小排序
	UpdatedAt   string `json:"updated_at"` // "2025-11-01T11:46:55.870Z"
	Id          string `json:"id"`
}

type EpsResp

type EpsResp struct {
	Eps struct {
		Docs  []Episode `json:"docs"`
		Stats `json:",squash"`
	} `json:"eps"`
}

func Episodes

func Episodes(ctx context.Context, bookId string, page int) (*EpsResp, error)

Episodes 获取章节列表, page 可为 -1

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error 附带了更详细的信息

pcErr := PicaComic.UnwarpErr(err)
isXxx := pcErr.Is(PicaComic.ErrXXX)

-

func UnwrapErr

func UnwrapErr(err error) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FavouriteResp

type FavouriteResp struct {
	Action string `json:"action"` // "favourite" | "un_favourite"
}

func Favourite

func Favourite(ctx context.Context, bookId string) (*FavouriteResp, error)

Favourite 收藏

type Image

type Image struct {
	Ii   ImageInfo
	P    int
	Data []byte
	Type ImageType
}

func (*Image) String

func (p *Image) String() string

type ImageInfo

type ImageInfo struct {
	FileServer   string `json:"fileServer"`
	OriginalName string `json:"originalName"`
	Path         string `json:"path"`
}

func (ImageInfo) Download

func (i ImageInfo) Download(ctx context.Context) (resp *http.Response, body []byte, err error)

func (ImageInfo) String

func (i ImageInfo) String() string

func (ImageInfo) Url

func (i ImageInfo) Url() *url.URL

type ImageType

type ImageType int
const (
	IMAGE_TYPE_UNKNOWN ImageType = iota

	IMAGE_TYPE_WEBP
	IMAGE_TYPE_JPEG
	IMAGE_TYPE_PNG
)

func (ImageType) String

func (it ImageType) String() string

type KeywordsResp

type KeywordsResp struct {
	Keywords []string `json:"keywords"`
}

func Keywords

func Keywords(ctx context.Context) (*KeywordsResp, error)

Keywords 紳士都在搜的關鍵字

type LikeResp

type LikeResp struct {
	Action string `json:"action"` // "like" | "unlike"
}

func Like

func Like(ctx context.Context, bookId string) (*LikeResp, error)

Like 讚好

type PageDoc

type PageDoc struct {
	UnderlineId string    `json:"_id"`
	Media       ImageInfo `json:"media"`
	Id          string    `json:"id"`
}

type PagesResp

type PagesResp struct {
	Pages struct {
		Docs  []PageDoc `json:"docs"`
		Stats `json:",squash"`
	} `json:"pages"`
	Ep struct {
		Id    string `json:"_id"`
		Title string `json:"title"`
	} `json:"ep"`
}

func Pages

func Pages(ctx context.Context, bookId string, epId, page int) (*PagesResp, error)

Pages 获取图片列表, page 可为 -1

type RecommendationComic

type RecommendationComic struct {
	Id         string    `json:"_id"`
	Title      string    `json:"title"`
	Author     string    `json:"author"`
	PagesCount int       `json:"pagesCount"`
	EpsCount   int       `json:"epsCount"`
	Finished   bool      `json:"finished"`
	Categories []string  `json:"categories"`
	Thumb      ImageInfo `json:"thumb"`
	LikesCount int       `json:"likesCount"`
}

type RecommendationResp

type RecommendationResp struct {
	Comics []RecommendationComic
}

func Recommendation

func Recommendation(ctx context.Context, bookId string) (*RecommendationResp, error)

Recommendation 看了這本子的人也在看

type SearchComic

type SearchComic struct {
	UpdatedAt   string    `json:"updated_at"`
	Thumb       ImageInfo `json:"thumb"`
	Author      string    `json:"author"`
	Description string    `json:"description"`
	ChineseTeam string    `json:"chineseTeam"`
	CreatedAt   string    `json:"created_at"`
	Finished    bool      `json:"finished"`
	TotalViews  int       `json:"totalViews"`
	Categories  []string  `json:"categories"`
	TotalLikes  int       `json:"totalLikes"` // 有些本没有, 优先 {.LikesCount}
	Title       string    `json:"title"`
	Tags        []string  `json:"tags"`
	Id          string    `json:"_id"`
	LikesCount  int       `json:"likesCount"`
}

type SearchResp

type SearchResp struct {
	Comics struct {
		Docs  []SearchComic `json:"docs"`
		Stats `json:",squash"`
	} `json:"comics"`
}
func Search(ctx context.Context, keyword string, categories []string, sort Sort, page uint) (*SearchResp, error)

type SignInResp

type SignInResp struct {
	Token string `json:"token"`
}

func SignIn

func SignIn(ctx context.Context, email, password string) (*SignInResp, error)

type Sort

type Sort = string
const (
	ORDER_DEFAULT Sort = "ua" // 默认
	ORDER_LATEST  Sort = "dd" // 新到舊
	ORDER_OLDEST  Sort = "da" // 舊到新
	ORDER_LOVED   Sort = "ld" // 最多愛心
	ORDER_POINT   Sort = "vd" // 最多紳士指名
)

type Stats

type Stats struct {
	Total int `json:"total"` // 总数
	Limit int `json:"limit"` // 返回数 == len(.Docs)
	Pages int `json:"pages"` // 共几页
	Page  int `json:"page"`  // 第几页
}

type User

type User struct {
	Id         string    `json:"_id"`
	Gender     string    `json:"gender"` // "m" | "f"?
	Name       string    `json:"name"`
	Title      string    `json:"title"` // "WANDANCE"
	Verified   bool      `json:"verified"`
	Exp        int       `json:"exp"`
	Level      int       `json:"level"`
	Characters []string  `json:"characters"` // "knight", "vip", "single_doc", "tool_man"
	Role       string    `json:"role"`       // "knight"
	Avatar     ImageInfo `json:"avatar"`
	Slogan     string    `json:"slogan"` // 签名

}

type UserFavouriteComic

type UserFavouriteComic struct {
	Id         string    `json:"_id"`
	Title      string    `json:"title"`
	Author     string    `json:"author"`
	TotalViews int       `json:"totalViews"`
	TotalLikes int       `json:"totalLikes"`
	PagesCount int       `json:"pagesCount"`
	EpsCount   int       `json:"epsCount"`
	Finished   bool      `json:"finished"`
	Categories []string  `json:"categories"`
	Tags       []string  `json:"tags"`
	Thumb      ImageInfo `json:"thumb"`
	LikesCount int       `json:"likesCount"`
}

type UserFavouriteResp

type UserFavouriteResp struct {
	Comics struct {
		Docs  []UserFavouriteComic `json:"docs"`
		Stats `json:",squash"`
	}
}

func UserFavourite

func UserFavourite(ctx context.Context, sort Sort, page int) (*UserFavouriteResp, error)

UserFavourite 已收藏, page 可为 -1

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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