personal.go 859 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package core
  2. import (
  3. session "codeberg.org/vnpower/pixivfe/v2/core/session"
  4. http "codeberg.org/vnpower/pixivfe/v2/core/http"
  5. "github.com/goccy/go-json"
  6. "github.com/gofiber/fiber/v2"
  7. )
  8. func GetNewestFromFollowing(c *fiber.Ctx, mode, page string) ([]ArtworkBrief, error) {
  9. token := session.GetPixivToken(c)
  10. URL := http.GetNewestFromFollowingURL(mode, page)
  11. var body struct {
  12. Thumbnails json.RawMessage `json:"thumbnails"`
  13. }
  14. var artworks struct {
  15. Artworks []ArtworkBrief `json:"illust"`
  16. }
  17. resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
  18. if err != nil {
  19. return nil, err
  20. }
  21. resp = session.ProxyImageUrl(c, resp)
  22. err = json.Unmarshal([]byte(resp), &body)
  23. if err != nil {
  24. return nil, err
  25. }
  26. err = json.Unmarshal([]byte(body.Thumbnails), &artworks)
  27. if err != nil {
  28. return nil, err
  29. }
  30. return artworks.Artworks, nil
  31. }