Skip to content

Commit

Permalink
Merge pull request #1 from littleneko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
littleneko authored Apr 27, 2023
2 parents 2b0f64f + bbcabde commit 2e116b5
Show file tree
Hide file tree
Showing 8 changed files with 1,212 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# pixiv-api-go

A pixiv ajax(web) api

## How to Use

```go
package main

import "github.com/littleneko/pixiv-api-go"

func main() {

client := pixiv_api_go.NewPixivClient(5000)
client.SetUserAgent("")
client.SetCookiePHPSESSID("")

illusts, _ := client.GetIllustInfo("107157430", false)
for illust := range illusts {
println(illust)
}
}

```
24 changes: 24 additions & 0 deletions constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pixiv_api_go

const (
IllustRankModeDaily IllustRankMode = "daily" // 今日
IllustRankModeWeekly IllustRankMode = "weekly" // 本周
IllustRankModeMonthly IllustRankMode = "monthly" // 本月
IllustRankModeRookie IllustRankMode = "rookie" // 新人
IllustRankModeDailyAi IllustRankMode = "daily_ai" // AI 生成
IllustRankModeMale IllustRankMode = "male" // 受男性欢迎
IllustRankModeFemale IllustRankMode = "female" // 受女性欢迎
IllustRankModeDailyR18 IllustRankMode = "daily_r18"
IllustRankModeWeeklyR18 IllustRankMode = "weekly_r18"
IllustRankModeDailyR18Ai IllustRankMode = "daily_r18_ai"
IllustRankModeMaleR18 IllustRankMode = "male_r18"
IllustRankModeFemaleR18 IllustRankMode = "female_r18"
IllustRankModeR18g IllustRankMode = "r18g"
)

const (
IllustRankContentAll IllustRankContent = "all" // 综合
IllustRankContentIllust IllustRankContent = "illust" // 插画
IllustRankContentUgoira IllustRankContent = "ugoira" // 动图
IllustRankContentManga IllustRankContent = "manga" // 漫画
)
24 changes: 24 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pixiv_api_go

import (
"errors"
"fmt"
)

var (
// ErrNotFound means the api return 404
ErrNotFound = errors.New("NotFound")
)

type ErrorJsonUnmarshal struct {
err error
rawStr string
}

func NewJsonUnmarshalErr(date []byte, err error) error {
return &ErrorJsonUnmarshal{err: err, rawStr: string(date)}
}

func (j *ErrorJsonUnmarshal) Error() string {
return fmt.Sprintf("failed to unmarshal json, err: %s, raw: %s", j.err, j.rawStr)
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module pixiv-api-go

go 1.19
Loading

0 comments on commit 2e116b5

Please sign in to comment.