Discovery page

This commit is contained in:
VnPower
2024-01-01 21:12:59 +07:00
parent e4d7e36b08
commit e4da9d061d
5 changed files with 60 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
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"
"github.com/tidwall/gjson"
)
func GetDiscoveryArtwork(c *fiber.Ctx, mode string) ([]ArtworkBrief, error) {
imageProxy := session.GetImageProxy(c)
URL := http.GetDiscoveryURL(mode, 100)
var artworks []ArtworkBrief
resp, err := http.UnwrapWebAPIRequest(URL)
println("here")
if err != nil {
return nil, err
}
resp = ProxyImages(resp, imageProxy)
data := gjson.Get(resp, "thumbnails.illust").String()
err = json.Unmarshal([]byte(data), &artworks)
if err != nil {
return nil, err
}
return artworks, nil
}