mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
ba3ec43559
thanks semgrep! Squashed commit of the following: commit 3a5e08190583804d3b330ecc6cb3422bc04c291b Author: iacore <noreply+gpg-stub@1a-insec.net> Date: Fri Feb 9 12:58:07 2024 +0000 final commit f1cdc73e9f8d331715de8e8aec5d1573218df0c3 Author: iacore <noreply+gpg-stub@1a-insec.net> Date: Fri Feb 9 12:50:23 2024 +0000 manual tweak commit 3a3ba2b8d8d7ce9af4d897288596d9318c715a08 Author: iacore <noreply+gpg-stub@1a-insec.net> Date: Fri Feb 9 12:49:15 2024 +0000 stage 1
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package core
|
|
|
|
import (
|
|
session "codeberg.org/vnpower/pixivfe/v2/core/config"
|
|
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
|
"github.com/goccy/go-json"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type ArtworkBrief struct {
|
|
ID string `json:"id"`
|
|
Title string `json:"title"`
|
|
ArtistID string `json:"userId"`
|
|
ArtistName string `json:"userName"`
|
|
ArtistAvatar string `json:"profileImageUrl"`
|
|
Thumbnail string `json:"url"`
|
|
Pages int `json:"pageCount"`
|
|
XRestrict int `json:"xRestrict"`
|
|
AiType int `json:"aiType"`
|
|
Bookmarked any `json:"bookmarkData"`
|
|
}
|
|
|
|
func GetNewestArtworks(c *fiber.Ctx, worktype string, r18 string) ([]ArtworkBrief, error) {
|
|
token := session.GetToken(c)
|
|
URL := http.GetNewestArtworksURL(worktype, r18, "0")
|
|
|
|
var body struct {
|
|
Artworks []ArtworkBrief `json:"illusts"`
|
|
// LastId string
|
|
}
|
|
|
|
resp, err := http.UnwrapWebAPIRequest(URL, token)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp = session.ProxyImageUrl(resp)
|
|
|
|
err = json.Unmarshal([]byte(resp), &body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return body.Artworks, nil
|
|
}
|