Skip to content

Commit

Permalink
feat: support optional custom User Agent per-channel (#20, PR: #21)
Browse files Browse the repository at this point in the history
* feat: support optional custom User Agent per-channel

* fix(ci): run workflow when PR is opened
  • Loading branch information
duncanleo authored Dec 17, 2023
1 parent 2deb25d commit 71530c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test Build

on:
pull_request:
types: [synchronize]
types: [synchronize, opened]

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions config/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type Channel struct {
URL string `json:"url"`
ProxyConfig *ProxyConfig `json:"proxy"`
DisableTranscode bool `json:"disableTranscode"`

// UserAgent is a custom UA string that will be used by FFMPEG to make requests to the stream URL.
UserAgent *string `json:"userAgent,omitempty"`
}

var (
Expand Down
8 changes: 8 additions & 0 deletions routes/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ func Stream(c *gin.Context) {
)
}

if channel.UserAgent != nil {
ffmpegArgs = append(
ffmpegArgs,
"-headers",
fmt.Sprintf("User-Agent: %s", *channel.UserAgent),
)
}

switch config.Cfg.GetEncoderProfile() {
case config.EncoderProfileVAAPI:
ffmpegArgs = append(
Expand Down

0 comments on commit 71530c6

Please sign in to comment.