newest.go 638 B

12345678910111213141516171819202122232425262728293031
  1. package core
  2. import (
  3. "codeberg.org/vnpower/pixivfe/v2/session"
  4. "github.com/goccy/go-json"
  5. "github.com/gofiber/fiber/v2"
  6. )
  7. func GetNewestArtworks(c *fiber.Ctx, worktype string, r18 string) ([]ArtworkBrief, error) {
  8. token := session.GetPixivToken(c)
  9. URL := GetNewestArtworksURL(worktype, r18, "0")
  10. var body struct {
  11. Artworks []ArtworkBrief `json:"illusts"`
  12. // LastId string
  13. }
  14. resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
  15. if err != nil {
  16. return nil, err
  17. }
  18. resp = session.ProxyImageUrl(c, resp)
  19. err = json.Unmarshal([]byte(resp), &body)
  20. if err != nil {
  21. return nil, err
  22. }
  23. return body.Artworks, nil
  24. }