package main import ( "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/client" "git.dc09.ru/gopiped/schema/pubapi" ) const BaseUrl = "https://e73z33t5.dc09.ru" func main() { app := fiber.New() cc := client.New() app.Get("/", func(c fiber.Ctx) error { return c.SendString("dc09piped") }) app.Get("/watch", func(c fiber.Ctx) error { vid := c.Query("v") // TODO: return error if vid == "" listen := c.Query("listen") == "1" resp, err := cc.Get(BaseUrl + "/streams/" + vid) if err != nil { return err } if resp.StatusCode() != 200 { return c.Send(resp.Body()) } var data pubapi.Streams resp.JSON(&data) // TODO: templating // TODO: sort+filter streams if listen { return c.SendString(data.AudioStreams[0].Url) } else { return c.SendString(data.VideoStreams[0].Url) } }) app.Listen("127.0.0.1:4800", fiber.ListenConfig{ EnablePrefork: true, }) }