Remove dynamic playlist image (no point + slow to generate)

This commit is contained in:
Eccentric 2024-02-11 18:33:57 +00:00
parent 5bd856e04f
commit db3d60748a
3 changed files with 24 additions and 39 deletions

View File

@ -18,13 +18,13 @@ var (
type ExternalDataClient struct {
h *http.Client
FortniteSets map[string]*FortniteSet
FortniteItems map[string]*FortniteItem
FortniteItemsWithDisplayAssets map[string]*FortniteItem
FortniteItemsWithFeaturedImage []*FortniteItem
TypedFortniteItems map[string][]*FortniteItem
TypedFortniteItemsWithDisplayAssets map[string][]*FortniteItem
SnowVariantTokens map[string]SnowCosmeticVariantToken
FortniteSets map[string]*FortniteSet `json:"sets"`
FortniteItems map[string]*FortniteItem `json:"items"`
FortniteItemsWithDisplayAssets map[string]*FortniteItem `json:"-"`
FortniteItemsWithFeaturedImage []*FortniteItem `json:"-"`
TypedFortniteItems map[string][]*FortniteItem `json:"-"`
TypedFortniteItemsWithDisplayAssets map[string][]*FortniteItem `json:"-"`
SnowVariantTokens map[string]SnowCosmeticVariantToken `json:"-"`
}
func NewExternalDataClient() *ExternalDataClient {

View File

@ -1,11 +1,9 @@
package handlers
import (
"math/rand"
"strconv"
"github.com/ectrc/snow/aid"
"github.com/ectrc/snow/fortnite"
"github.com/gofiber/fiber/v2"
)
@ -75,10 +73,7 @@ func createPlaylist(mnemonic string, image string) aid.JSON {
func PostDiscovery(c *fiber.Ctx) error {
results := []aid.JSON{}
for playlist := range fortnite.PlaylistImages {
results = append(results, createPlaylist(playlist, "https://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999))))
}
results = append(results, createPlaylist("Playlist_DefaultSolo", "http://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png"))
results = append(results, createPlaylist("Playlist_DefaultSolo", "https://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png"))
return c.Status(200).JSON(aid.JSON{
"Panels": []aid.JSON{
@ -156,13 +151,13 @@ func GetContentPages(c *fiber.Ctx) error {
seasonString := strconv.Itoa(aid.Config.Fortnite.Season)
playlists := []aid.JSON{}
for playlist := range fortnite.PlaylistImages {
playlists = append(playlists, aid.JSON{
"image": "http://" +aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)),
"playlist_name": playlist,
"hidden": false,
})
}
// for playlist := range fortnite.PlaylistImages {
// playlists = append(playlists, aid.JSON{
// "image": "http://" +aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)),
// "playlist_name": playlist,
// "hidden": false,
// })
// }
backgrounds := []aid.JSON{}
switch aid.Config.Fortnite.Season {

View File

@ -1,8 +1,6 @@
package handlers
import (
"strings"
"github.com/ectrc/snow/aid"
"github.com/ectrc/snow/fortnite"
p "github.com/ectrc/snow/person"
@ -10,26 +8,18 @@ import (
"github.com/gofiber/fiber/v2"
)
func MiddlewareOnlyDebug(c *fiber.Ctx) error {
if aid.Config.API.Debug {
return c.Next()
}
return c.SendStatus(403)
}
func GetPreloadedCosmetics(c *fiber.Ctx) error {
return c.JSON(fortnite.External)
}
func GetPlaylistImage(c *fiber.Ctx) error {
playlist := c.Params("playlist")
if playlist == "" {
return c.SendStatus(404)
}
playlist = strings.Split(playlist, ".")[0]
image, ok := fortnite.PlaylistImages[playlist]
if !ok {
return c.SendStatus(404)
}
c.Set("Content-Type", "image/png")
return c.Send(image)
}
func GetPlayerLocker(c *fiber.Ctx) error {
person := c.Locals("person").(*p.Person)