mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2025-02-07 04:08:10 -05:00
New stream endpoint
This commit is contained in:
parent
b2cc516967
commit
785e38ea29
1 changed files with 34 additions and 0 deletions
|
@ -42,4 +42,38 @@ func Routes(route *gin.Engine) {
|
|||
|
||||
context.Data(200, "application/text", []byte(playlistFile))
|
||||
})
|
||||
|
||||
auth.GET("/stream/sub/:encodedUrl", func(context *gin.Context) {
|
||||
decodedUrl, err := b64.StdEncoding.DecodeString(context.Param("encodedUrl"))
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
}
|
||||
|
||||
playlistFile, err := twitch.GetSubPlaylist(string(decodedUrl))
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
}
|
||||
|
||||
context.Data(200, "application/text", []byte(playlistFile))
|
||||
})
|
||||
|
||||
auth.GET("/stream/segment/:encodedUrl", func(context *gin.Context) {
|
||||
decodedUrl, err := b64.StdEncoding.DecodeString(context.Param("encodedUrl"))
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
}
|
||||
|
||||
segmentData, err := http.Get(string(decodedUrl))
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
segment, err := io.ReadAll(segmentData.Body)
|
||||
if err != nil {
|
||||
context.Error(err)
|
||||
}
|
||||
|
||||
context.Data(200, "fuck", segment)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue