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

50 lines
1.1 KiB
Go
Raw Normal View History

2023-07-17 12:16:33 -05:00
package vods
import (
"safetwitch-backend/extractor"
"safetwitch-backend/extractor/twitch"
2023-07-19 19:27:36 -05:00
"strconv"
2023-07-17 12:16:33 -05:00
"github.com/gin-gonic/gin"
)
func Routes(route *gin.Engine) {
2023-07-19 19:27:36 -05:00
vods := route.Group("/api/vods")
2023-07-17 12:16:33 -05:00
2023-07-19 19:27:36 -05:00
vods.GET("/shelve/:streamerName", func(context *gin.Context) {
2023-07-17 12:16:33 -05:00
data, err := twitch.GetStreamerVideoShelves(context.Param("streamerName"))
if err != nil {
context.Error(err)
return
}
context.JSON(200, extractor.FormatMessage(data, true))
})
2023-07-20 13:40:34 -05:00
vods.GET("/:vodID", func(context *gin.Context) {
data, err := twitch.GetVodMetadata(context.Param("vodID"))
2023-07-17 12:16:33 -05:00
if err != nil {
context.Error(err)
return
}
2023-07-20 13:40:34 -05:00
data.Type = "vod"
2023-07-17 12:16:33 -05:00
context.JSON(200, extractor.FormatMessage(data, true))
})
2023-07-19 19:27:36 -05:00
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))
})
2023-07-17 12:16:33 -05:00
}