0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2024-12-22 21:23:01 -05:00
safetwitch-backend/routes/api/vods/vods.go
2023-07-20 14:40:54 -04:00

49 lines
1.1 KiB
Go

package vods
import (
"safetwitch-backend/extractor"
"safetwitch-backend/extractor/twitch"
"strconv"
"github.com/gin-gonic/gin"
)
func Routes(route *gin.Engine) {
vods := route.Group("/api/vods")
vods.GET("/shelve/:streamerName", func(context *gin.Context) {
data, err := twitch.GetStreamerVideoShelves(context.Param("streamerName"))
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
vods.GET("/:vodID", func(context *gin.Context) {
data, err := twitch.GetVodMetadata(context.Param("vodID"))
if err != nil {
context.Error(err)
return
}
data.Type = "vod"
context.JSON(200, extractor.FormatMessage(data, true))
})
vods.GET("/comments/:vodID/:offset", func(context *gin.Context) {
offset := context.Param("offset")
o, err := strconv.Atoi(offset)
if err != nil {
context.Error(err)
return
}
data, err := twitch.GetVODChat(context.Param("vodID"), o)
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
}