mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
a8aaefef37
This commit restores the ability to use a user-provided token when making API requests and gives it precedence over the default token provided by tokenManager. Additionally, the function GetPixivToken has been renamed to GetUserToken for clarity.
31 lines
627 B
Go
31 lines
627 B
Go
package core
|
|
|
|
import (
|
|
"codeberg.org/vnpower/pixivfe/v2/server/session"
|
|
"github.com/goccy/go-json"
|
|
"net/http"
|
|
)
|
|
|
|
func GetNewestArtworks(r *http.Request, worktype string, r18 string) ([]ArtworkBrief, error) {
|
|
token := session.GetUserToken(r)
|
|
URL := GetNewestArtworksURL(worktype, r18, "0")
|
|
|
|
var body struct {
|
|
Artworks []ArtworkBrief `json:"illusts"`
|
|
// LastId string
|
|
}
|
|
|
|
resp, err := API_GET_UnwrapJson(r.Context(), URL, token)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp = session.ProxyImageUrl(r, resp)
|
|
|
|
err = json.Unmarshal([]byte(resp), &body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return body.Artworks, nil
|
|
}
|