Skip to content

Commit

Permalink
👋 my geek time
Browse files Browse the repository at this point in the history
  • Loading branch information
zkep committed Dec 26, 2024
1 parent 88e03b8 commit 00fb2e6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/api/v2/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,21 @@ func (t *Task) Play(c *gin.Context) {
break
}
ln := string(line)
if strings.HasSuffix(ln, ".ts") {
if strings.HasPrefix(ln, "#EXT-X-KEY:") {
sps := strings.Split(ln, `"`)
token, _, er := global.JWT.TokenGenerator(func(claims jwt.MapClaims) {
claims["task_id"] = l.TaskId
now := time.Now().UTC()
expire := now.Add(time.Minute)
claims["exp"] = expire.Unix()
claims["orig_iat"] = now.Unix()
})
if er != nil {
global.FAIL(c, "fail.msg", er.Error())
return
}
ln = fmt.Sprintf(`%s"%s/v2/task/kms?Ciphertext=%s"`, sps[0], global.CONF.Storage.Host, token)
} else if strings.HasSuffix(ln, ".ts") {
if strings.HasPrefix(ln, "https://res001.geekbang.org") {
ln = "/v2/task/play/part?p=" + ln
}
Expand Down

0 comments on commit 00fb2e6

Please sign in to comment.