personal.go 770 B

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