pica

package module
v0.0.0-...-3498c4f Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 15 Imported by: 0

README

PICA-GO

Golang哔卡漫画API

实现功能

  • 用户
    • 登录 / 注册 / 获取用户信息 / 打卡 / 我的评论
    • 变更密码 / 变更签名 / 变更头像
  • 漫画
    • 分类 / 搜索 / 大家都在搜 / 随机本子 / 排行榜 / 推荐
    • 收藏 / 喜欢 / 获取EP / 获取图片
    • 看这个本子的也在看 / 评论 / 获取评论 / 子评论
  • 游戏
    • 评论 / 获取评论 / 子评论
  • 社交
    • 大家都在搜
  • 网络

使用方法

package main

import "github.com/niuhuan/pica-go"

func main(){
  client := pica.Client{}  
  err := client.Login(username, password)
  comicsPage, err := client.Comics("", "", "", "", pica.SortDefault, 1)
}

Documentation

Overview

Package pica 哔咔漫画Golang客户端

Index

Constants

View Source
const (
	SortDefault    = "ua"
	SortTimeNewest = "dd" // 新到旧
	SortTimeOldest = "da" // 旧到新
	SortLikeMost   = "ld" // 最多爱心
	SortViewMost   = "vd" // 最多绅士指名
)

排序方式

View Source
const (
	ImageQualityOriginal = "original"
	ImageQualityLow      = "low"
	ImageQualityMedium   = "medium"
	ImageQualityHigh     = "high"
)

图片质量

View Source
const (
	ActionLike        = "like"
	ActionUnlike      = "unlike"
	ActionFavourite   = "favourite"
	ActionUnFavourite = "un_favourite"
)

请求结果

View Source
const (
	LeaderboardH24 = "H24"
	LeaderboardD7  = "D7"
	LeaderboardD30 = "D30"
)

排行榜类型

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResponse

type ActionResponse struct {
	Data struct {
		Action string `json:"action"`
	} `json:"data"`
}

ActionResponse 点赞,收藏 等接口返回体

type CategoriesResponse

type CategoriesResponse struct {
	Response
	Data struct {
		Categories []Category `json:"categories"`
	} `json:"data"`
}

CategoriesResponse 获取分类接口返回体

type Category

type Category struct {
	Id          string `json:"_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Thumb       Image  `json:"thumb"`
	IsWeb       bool   `json:"isWeb"`
	Active      bool   `json:"active"`
	Link        string `json:"link"`
}

Category 分类

type ChildOfComment

type ChildOfComment struct {
	Parent string `json:"_parent"`
}

ChildOfComment 自评的字段

type Client

type Client struct {
	http.Client
	Token string
}

Client 客户端 struct

func (*Client) Categories

func (client *Client) Categories() ([]Category, error)

Categories 获取分类

func (*Client) Collections

func (client *Client) Collections() ([]Collection, error)

func (*Client) ComicCommentsPage

func (client *Client) ComicCommentsPage(comicId string, page int) (*CommentsPage, error)

ComicCommentsPage 漫画的评论

func (*Client) ComicEpPage

func (client *Client) ComicEpPage(comicId string, page int) (*EpPage, error)

ComicEpPage 漫画EP信息

func (*Client) ComicInfo

func (client *Client) ComicInfo(comicId string) (*ComicInfo, error)

ComicInfo 漫画详情

func (*Client) ComicPicture

func (client *Client) ComicPicture(pictureInfo Image) ([]byte, error)

ComicPicture 获取实际的漫画图片,不需要login

func (*Client) ComicPicturePage

func (client *Client) ComicPicturePage(comicId string, epOrder int, page int) (*ComicPicturePage, error)

ComicPicturePage 漫画图片

func (*Client) ComicPicturePageWithQuality

func (client *Client) ComicPicturePageWithQuality(comicId string, epOrder int, page int, quality string) (*ComicPicturePage, error)

ComicPicturePageWithQuality 漫画图片

func (*Client) ComicRecommendation

func (client *Client) ComicRecommendation(comicId string) ([]ComicSimple, error)

ComicRecommendation 看了这个本子的也在看

func (*Client) Comics

func (client *Client) Comics(category string, tag string, creatorId string, chineseTeam string, sort string, page int) (*ComicsPage, error)

Comics 分类下的漫画 category 为空字符串则为所有分类

func (*Client) CommentChildren

func (client *Client) CommentChildren(commentId string, page int) (*CommentChildrenPage, error)

CommentChildren 获取子评论

func (*Client) FavouriteComics

func (client *Client) FavouriteComics(sort string, page int) (*ComicsPage, error)

FavouriteComics 收藏的漫画

func (*Client) ForgotPassword

func (client *Client) ForgotPassword(email string) (*ForgotPasswordResult, error)

ForgotPassword 找回密码, 获取用户问题

func (*Client) GameCommentChildren

func (client *Client) GameCommentChildren(commentId string, page int) (*GameCommentChildrenPage, error)

GameCommentChildren 游戏评论的回复分页 (和漫画接口是同一个, 只有"_comic/_game"字段不一样)

func (*Client) GameCommentsPage

func (client *Client) GameCommentsPage(gameId string, page int) (*GameCommentsPage, error)

GameCommentsPage 游戏评论分页

func (*Client) GameInfo

func (client *Client) GameInfo(gameId string) (*GameInfo, error)

GameInfo 游戏详情

func (*Client) GamePage

func (client *Client) GamePage(page int) (*GamePage, error)

GamePage 游戏列表

func (*Client) HideComment

func (client *Client) HideComment(commentId string) error

HideComment 哔咔API里的接口, 不知道做什么用的, 推测是管理员用接口

func (*Client) HotKeywords

func (client *Client) HotKeywords() ([]string, error)

HotKeywords 大家都在搜

func (*Client) InitInfo

func (client *Client) InitInfo() (*InitInfo, error)

func (*Client) Leaderboard

func (client *Client) Leaderboard(leaderboardType string) ([]ComicSimple, error)

Leaderboard 排行榜

func (*Client) LeaderboardOfKnight

func (client *Client) LeaderboardOfKnight() ([]Knight, error)

LeaderboardOfKnight 骑士榜

func (*Client) Login

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

Login 登录, 登录无异常则注入TOKEN

func (*Client) MyComments

func (client *Client) MyComments(page int) (*MyCommentsPage, error)

func (*Client) PostChildComment

func (client *Client) PostChildComment(commentId string, content string) error

PostChildComment 对漫画/游戏的评论进行回复(子评论), 但是评论后无法删除

func (*Client) PostComment

func (client *Client) PostComment(comicId string, content string) error

PostComment 对漫画进行评论, 但是评论后无法删除

func (*Client) PostGameComment

func (client *Client) PostGameComment(gameId string, content string) error

PostGameComment 对游戏进行评论, 但是评论后无法删除

func (*Client) PunchIn

func (client *Client) PunchIn() (*PunchStatus, error)

PunchIn 打哔卡

func (*Client) RandomComics

func (client *Client) RandomComics() ([]ComicSimple, error)

RandomComics 随机漫画

func (*Client) Register

func (client *Client) Register(dto RegisterDto) error

Register 注册新用户

func (*Client) ResetPassword

func (client *Client) ResetPassword(email string, questionNo int, answer string) (*ResetPasswordResult, error)

ResetPassword 找回密码, 根据问题重置密码

func (*Client) SearchComics

func (client *Client) SearchComics(categories []string, keyword string, sort string, page int) (*ComicsPage, error)

SearchComics 搜索漫画 PS : 此接口并没有返回 PagesCount EpsCount

func (*Client) SearchComicsInCategories

func (client *Client) SearchComicsInCategories(keyword string, sort string, page int, categories []string) (*ComicsPage, error)

SearchComicsInCategories 搜索漫画

func (*Client) SwitchFavourite

func (client *Client) SwitchFavourite(comicId string) (*string, error)

SwitchFavourite (取消)收藏漫画 第一次收藏,第二次是取消收藏 action是最终结果

func (*Client) SwitchLike

func (client *Client) SwitchLike(comicId string) (*string, error)

SwitchLike (取消)喜欢漫画 第一次喜欢,第二次是取消喜欢 action是最终结果

func (*Client) SwitchLikeComment

func (client *Client) SwitchLikeComment(commentId string) (*string, error)

SwitchLikeComment (取消)喜欢评论/子评论 第一次喜欢,第二次是取消喜欢 action是最终结果 ( ActionLike or ActionUnlike )

func (*Client) UpdateAvatar

func (client *Client) UpdateAvatar(jpegBytes []byte) error

UpdateAvatar 修改头像 请压缩头像成正方形, 200x200,并尽量减少图片体积, 编码必须为JPEG

func (*Client) UpdatePassword

func (client *Client) UpdatePassword(oldPassword string, newPassword string) error

UpdatePassword 修改密码

func (*Client) UpdateSlogan

func (client *Client) UpdateSlogan(slogan string) error

UpdateSlogan 修改签名

func (*Client) UserProfile

func (client *Client) UserProfile() (*UserProfile, error)

UserProfile 用户信息

type Collection

type Collection struct {
	Title  string        `json:"title"`
	Comics []ComicSimple `json:"comics"`
}

Collection 合集

type CollectionsResponse

type CollectionsResponse struct {
	Response
	Data struct {
		Collections []Collection `json:"collections"`
	} `json:"data"`
}

CollectionsResponse 合集返回体

type ComicInfo

type ComicInfo struct {
	ComicSimple
	Creator       Creator   `json:"_creator"`
	Description   string    `json:"description"`
	ChineseTeam   string    `json:"chineseTeam"`
	Tags          []string  `json:"tags"`
	UpdatedAt     time.Time `json:"updated_at"`
	CreatedAt     time.Time `json:"created_at"`
	AllowDownload bool      `json:"allowDownload"`
	ViewsCount    int       `json:"viewsCount"`
	IsFavourite   bool      `json:"isFavourite"`
	IsLiked       bool      `json:"isLiked"`
	CommentsCount int       `json:"commentsCount"`
}

ComicInfo 漫画详情

type ComicInfoResponse

type ComicInfoResponse struct {
	Response
	Data struct {
		Comic ComicInfo `json:"comic"`
	} `json:"data" `
}

ComicInfoResponse 获取漫画详情接口返回体

type ComicPicture

type ComicPicture struct {
	Media Image  `json:"media"`
	Id    string `json:"_id"`
}

ComicPicture 章节的图片

type ComicPicturePage

type ComicPicturePage struct {
	PageData
	Docs []ComicPicture `json:"docs"`
}

ComicPicturePage 章节图片的分页

type ComicPicturePageResponse

type ComicPicturePageResponse struct {
	Response
	Data struct {
		Pages ComicPicturePage `json:"pages"`
		Ep    Ep               `json:"ep"`
	} `json:"data"`
}

ComicPicturePageResponse 获取章节图片接口返回体

type ComicSimple

type ComicSimple 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      Image    `json:"thumb"`
	LikesCount int      `json:"likesCount"`
}

ComicSimple 漫画摘要内容, 列表页面使用

type ComicsPage

type ComicsPage struct {
	PageData
	Docs []ComicSimple `json:"docs"`
}

ComicsPage 漫画的分页

type ComicsPageResponse

type ComicsPageResponse struct {
	Response
	Data struct {
		Comics ComicsPage `json:"comics"`
	} `json:"data"`
}

ComicsPageResponse 漫画列表接口返回体

type ComicsResponse

type ComicsResponse struct {
	Response
	Data struct {
		Comics []ComicSimple `json:"comics"`
	} `json:"data"`
}

ComicsResponse 漫画列表返回体 用于随机漫画, 排行榜等不分页的接口

type Comment

type Comment struct {
	CommentBase
	Comic string `json:"_comic"`
}

Comment 漫画的评论

type CommentBase

type CommentBase struct {
	Id            string      `json:"_id"`
	Content       string      `json:"content"`
	User          CommentUser `json:"_user"`
	IsTop         bool        `json:"isTop"`
	Hide          bool        `json:"hide"`
	CreatedAt     time.Time   `json:"created_at"`
	LikesCount    int         `json:"likesCount"`
	CommentsCount int         `json:"commentsCount"`
	IsLiked       bool        `json:"isLiked"`
}

CommentBase 评论

type CommentChild

type CommentChild struct {
	Comment
	ChildOfComment
}

CommentChild 子评论

type CommentChildrenPage

type CommentChildrenPage struct {
	PageData
	Docs []CommentChild `json:"docs"`
}

CommentChildrenPage 子评论分页

type CommentChildrenResponse

type CommentChildrenResponse struct {
	Response
	Data struct {
		Comments CommentChildrenPage `json:"comments"`
	} `json:"data"`
}

CommentChildrenResponse 获取子评论接口返回体

type CommentUser

type CommentUser struct {
	UserBasic
	Role string `json:"role"`
}

CommentUser 发出此评论的人

type CommentsPage

type CommentsPage struct {
	PageData
	Docs []Comment `json:"docs"`
}

CommentsPage 漫画评论的分页

type CommentsResponse

type CommentsResponse struct {
	Response
	Data struct {
		Comments    CommentsPage `json:"comments"`
		TopComments []Comment    `json:"topComments"`
	} `json:"data"`
}

CommentsResponse 获取漫画评论接口返回体

type Creator

type Creator struct {
	UserBasic
	Role      string `json:"role"`
	Character string `json:"character"`
}

Creator 漫画的创建人

type Ep

type Ep struct {
	Id        string    `json:"_id"`
	Title     string    `json:"title"`
	Order     int       `json:"order"`
	UpdatedAt time.Time `json:"updated_at"`
}

Ep 漫画的章节

type EpPage

type EpPage struct {
	PageData
	Docs []Ep `json:"docs"`
}

EpPage 漫画的章节的分页

type EpPageResponse

type EpPageResponse struct {
	Response
	Data struct {
		Eps EpPage `json:"eps"`
	} `json:"data"`
}

EpPageResponse 获取漫画章节列表接口返回体

type ForgotPasswordResponse

type ForgotPasswordResponse struct {
	Response
	Data ForgotPasswordResult `json:"data"`
}

ForgotPasswordResponse 找回密码-获取问题-返回

type ForgotPasswordResult

type ForgotPasswordResult struct {
	Question1 string `json:"question1"`
	Question2 string `json:"question2"`
	Question3 string `json:"question3"`
}

ForgotPasswordResult 找回密码-获取问题-返回DATA

type GameComment

type GameComment struct {
	CommentBase
	Game string `json:"_game"`
}

GameComment 游戏的评论

type GameCommentChild

type GameCommentChild struct {
	GameComment
	ChildOfComment
}

GameCommentChild 游戏子评论

type GameCommentChildrenPage

type GameCommentChildrenPage struct {
	PageData
	Docs []GameCommentChild `json:"docs"`
}

GameCommentChildrenPage 游戏子评论分页

type GameCommentChildrenResponse

type GameCommentChildrenResponse struct {
	Response
	Data struct {
		Comments GameCommentChildrenPage `json:"comments"`
	} `json:"data"`
}

GameCommentChildrenResponse 获取游戏子评论接口返回体

type GameCommentsPage

type GameCommentsPage struct {
	PageData
	Docs []GameComment `json:"docs"`
}

GameCommentsPage 游戏评论的分页

type GameCommentsResponse

type GameCommentsResponse struct {
	Response
	Data struct {
		Comments    GameCommentsPage `json:"comments"`
		TopComments []Comment        `json:"topComments"`
	} `json:"data"`
}

GameCommentsResponse 获取漫画评论接口返回体

type GameInfo

type GameInfo struct {
	GameSimple
	Description    string    `json:"description"`
	UpdateContent  string    `json:"updateContent"`
	VideoLink      string    `json:"videoLink"`
	Screenshots    []Image   `json:"screenshots"`
	CommentsCount  int       `json:"commentsCount"`
	DownloadsCount int       `json:"downloadsCount"`
	IsLiked        bool      `json:"isLiked"`
	AndroidLinks   []string  `json:"androidLinks"`
	AndroidSize    float32   `json:"androidSize"`
	IosLinks       []string  `json:"iosLinks"`
	IosSize        float32   `json:"iosSize"`
	UpdatedAt      time.Time `json:"updated_at"`
	CreatedAt      time.Time `json:"created_at"`
}

GameInfo 游戏详情

type GamePage

type GamePage struct {
	PageData
	Docs []GameSimple `json:"docs"`
}

GamePage 游戏列表

type GamePageResponse

type GamePageResponse struct {
	Response
	Data struct {
		Games GamePage `json:"games"`
	} `json:"data"`
}

GamePageResponse 游戏列表接口返回体

type GameResponse

type GameResponse struct {
	Response
	Data struct {
		Game GameInfo `json:"game"`
	} `json:"data"`
}

GameResponse 游戏详情接口返回体

type GameSimple

type GameSimple struct {
	Id         string `json:"_id"`
	Title      string `json:"title"`
	Version    string `json:"version"`
	Icon       Image  `json:"icon"`
	Publisher  string `json:"publisher"`
	Adult      bool   `json:"adult"`
	Suggest    bool   `json:"suggest"`
	LikesCount int    `json:"likesCount"`
	Android    bool   `json:"android"`
	Ios        bool   `json:"ios"`
}

GameSimple 游戏摘要

type HotKeywordsResponse

type HotKeywordsResponse struct {
	Response
	Data struct {
		Keywords []string `json:"keywords"`
	} `json:"data"`
}

HotKeywordsResponse 大家搜在搜接口返回体

type Image

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

Image 图片资源

type InitInfo

type InitInfo struct {
	Status    string   `json:"status"`
	Addresses []string `json:"addresses"`
	Waka      string   `json:"waka"`
	AdKeyword string   `json:"adKeyword"`
}

type Knight

type Knight struct {
	UserBasic
	Role           string `json:"role"`
	Character      string `json:"character"`
	ComicsUploaded int    `json:"comicsUploaded"`
}

Knight 用户(骑士榜)

type LeaderboardOfKnightResponse

type LeaderboardOfKnightResponse struct {
	Response
	Data struct {
		Users []Knight `json:"users"`
	} `json:"data"`
}

LeaderboardOfKnightResponse 骑士榜接口返回体

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

LoginRequest 登录的请求体 (PS:Email字段为账号, 并不一定是邮箱格式)

type LoginResponse

type LoginResponse struct {
	Response
	Data struct {
		Token string `json:"token"`
	} `json:"data"`
}

LoginResponse 登录的返回体

type MyComment

type MyComment struct {
	Id      string `json:"_id"`
	Content string `json:"content"`
	Comic   struct {
		Id    string `json:"_id"`
		Title string `json:"title"`
	} `json:"_comic"`
	Hide          bool      `json:"hide"`
	CreatedAt     time.Time `json:"created_at"`
	LikesCount    int       `json:"likesCount"`
	CommentsCount int       `json:"commentsCount"`
	IsLiked       bool      `json:"isLiked"`
}

MyComment 我的评论

type MyCommentsPage

type MyCommentsPage struct {
	PageData
	Docs []MyComment `json:"docs"`
}

MyCommentsPage 我的评论分页

type MyCommentsPageResponse

type MyCommentsPageResponse struct {
	Response
	Data struct {
		Comments MyCommentsPage `json:"comments"`
	} `json:"data"`
}

MyCommentsPageResponse 我的评论接口返回体

type PageData

type PageData struct {
	Total int `json:"total"`
	Limit int `json:"limit"`
	Page  int `json:"page"`
	Pages int `json:"pages"`
}

PageData 分页格式

type PunchResponse

type PunchResponse struct {
	Response
	Data struct {
		Res PunchStatus `json:"res"`
	} `json:"data"`
}

PunchResponse 打哔咔接口返回体

type PunchStatus

type PunchStatus struct {
	Status         string `json:"status"`
	PunchInLastDay string `json:"punchInLastDay"`
}

PunchStatus 打哔咔接口返回内容

type RegisterDto

type RegisterDto struct {
	Email     string `json:"email"`    // 邮箱
	Password  string `json:"password"` // 8字以上
	Name      string `json:"name"`     // 2 - 50 字
	Birthday  string `json:"birthday"` // 2012-01-01
	Gender    string `json:"gender"`   // m, f, bot
	Answer1   string `json:"answer1"`
	Answer2   string `json:"answer2"`
	Answer3   string `json:"answer3"`
	Question1 string `json:"question1"`
	Question2 string `json:"question2"`
	Question3 string `json:"question3"`
}

RegisterDto 注册接口请求体

type ResetPasswordResponse

type ResetPasswordResponse struct {
	Response
	Data ResetPasswordResult `json:"data"`
}

ResetPasswordResponse 找回密码-获取问题-返回

type ResetPasswordResult

type ResetPasswordResult struct {
	Password string `json:"password"`
}

ResetPasswordResult 找回密码-根据答案重置密码

type Response

type Response struct {
	Code    int    `json:"code"`
	Error   string `json:"error"`
	Message string `json:"message"`
	Detail  string `json:"detail"`
}

Response 返回体格式

type UserBasic

type UserBasic struct {
	Id         string   `json:"_id"`
	Gender     string   `json:"gender"`
	Name       string   `json:"name"`
	Title      string   `json:"title"`
	Verified   bool     `json:"verified"`
	Exp        int      `json:"exp"`
	Level      int      `json:"level"`
	Characters []string `json:"characters"`
	Avatar     Image    `json:"avatar"`
	Slogan     string   `json:"slogan"` // 有可能是null, 从未设置过slogan的人
}

UserBasic 用户的基本信息

type UserProfile

type UserProfile struct {
	UserBasic
	Birthday  string    `json:"birthday"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
	IsPunched bool      `json:"isPunched"` // 是否打了哔咔
}

UserProfile 获取个人信息接口返回内容 | 个人信息

type UserProfileResponse

type UserProfileResponse struct {
	Data struct {
		User UserProfile `json:"user"`
	} `json:"data"`
}

UserProfileResponse 获取个人信息接口返回体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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