Skip to content

Commit 9d49c95

Browse files
committed
refactor: 调整 HTTPStrm 和 AlistStrm 设置,优化 playbackInfo 处理
1 parent 6156c15 commit 9d49c95

3 files changed

Lines changed: 22 additions & 23 deletions

File tree

config/config.yaml.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ client: # 客户端过滤器
5656

5757
http_strm: # HTTPStrm 相关配置(Strm 文件内容是 标准 HTTP URL)
5858
enable: true # 是否开启 HttpStrm 重定向
59-
transcode: false # false:强制关闭转码 true:保持原有转码设置
59+
proxy: false # 是否允许流量经过媒体服务器(true: 允许串流、转码行为;false: 仅支持直接播放)FNTV无效
6060
final_url: true # 对 URL 进行重定向判断,找到非重定向地址再重定向给客户端,减少客户端重定向次数(适用于 Strm 内容是局域网地址但是想要在公网之中播放)
61-
prefix_list: # EmbyServer 中 Strm 文件的前缀(符合该前缀的 Strm 文件且被正确识别为 HTTP 协议都会路由到该规则下)
61+
prefix_list: # 媒体服务器中 Strm 文件的前缀(符合该前缀的 Strm 文件且被正确识别为 HTTP 协议都会路由到该规则下)
6262
- /media/strm/http
6363
- /media/strm/https
6464

6565
alist_strm: # AlistStrm 相关配置(Strm 文件内容是 Alist 上文件的路径,目前仅支持适配 Alist V3)
6666
enable: true # 是否启用 AlistStrm 重定向
67-
transcode: true # false:强制关闭转码 true:保持原有转码设置
67+
proxy: true # 是否允许流量经过媒体服务器(true: 允许串流、转码行为;false: 仅支持直接播放)FNTV无效
6868
raw_url: false # Fasle:响应 Alist 服务器的直链(要求客户端可以访问到 Alist) true:直接响应 Alist 上游的真实链接(alist api 中的 raw_url 属性)
6969
list: # Alist 服务关配置列表
7070
- addr: http://192.168.1.100:5244 # Alist 服务器地址
7171
username: admin # Alist 服务器账号
7272
password: adminadmin # Alist 服务器密码
73-
prefix_list: # EmbyServer 中 Strm 文件的前缀(符合该前缀的 Strm 文件都会路由到该规则下)
73+
prefix_list: # 媒体服务器中 Strm 文件的前缀(符合该前缀的 Strm 文件都会路由到该规则下)
7474
- /media/strm/MyAlist # 同一个 Alist 可以有多个前缀规则
7575
- /mnt/cd2/strm
7676
- addr: https://xiaoya.com # 可以填写多个配置

internal/config/type.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type ClientFilterSetting struct {
6868
// HTTPStrm播放设置
6969
type HTTPStrmSetting struct {
7070
Enable bool `yaml:"enable"`
71-
TransCode bool `yaml:"transcode"` // false->强制关闭转码 true->保持原有转码设置
71+
Proxy bool `yaml:"proxy"` // 开启后支持媒体服务器串流、转码播放
7272
FinalURL bool `yaml:"final_url"` // 对 URL 进行重定向判断,找到非重定向地址再重定向给客户端,减少客户端重定向次数
7373
PrefixList []string `yaml:"prefix_list"`
7474
}
@@ -84,10 +84,10 @@ type AlistSetting struct {
8484

8585
// AlistStrm播放设置
8686
type AlistStrmSetting struct {
87-
Enable bool `yaml:"enable"`
88-
TransCode bool `yaml:"transcode"` // false->强制关闭转码 true->保持原有转码设置
89-
RawURL bool `yaml:"raw_url"` // 是否使用原始 URL
90-
List []AlistSetting `yaml:"list"`
87+
Enable bool `yaml:"enable"`
88+
Proxy bool `yaml:"proxy"` // 开启后支持媒体服务器串流、转码播放
89+
RawURL bool `yaml:"raw_url"` // 是否使用原始 URL
90+
List []AlistSetting `yaml:"list"`
9191
}
9292

9393
// 字幕设置

internal/handler/playbackInfo.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ func processHTTPStrmPlaybackInfo(jsonChain *utils.JsonChain, bsePath string, id
1818
logging.Debugf("处理 HTTPStrm %s PlaybackInfo 耗时:%s", id, time.Since(startTime))
1919
}()
2020

21-
if !config.HTTPStrm.TransCode {
21+
if !config.HTTPStrm.Proxy {
2222
jsonChain.Set(
23-
bsePath+"SupportsDirectPlay",
24-
true,
25-
).Set(
2623
bsePath+"SupportsDirectStream",
2724
false,
2825
).Set(
2926
bsePath+"SupportsTranscoding",
3027
false,
3128
).Delete(
3229
bsePath + "TranscodingUrl",
30+
).Delete(
31+
bsePath + "TranscodingContainer",
3332
).Delete(
3433
bsePath + "TranscodingSubProtocol",
3534
).Delete(
36-
bsePath + "TranscodingContainer",
35+
bsePath + "TrancodeLiveStartIndex",
3736
)
37+
3838
var msgs []string
3939
if directStreamURL != nil {
4040
msgs = append(msgs, fmt.Sprintf("原直链播放链接: %s", *directStreamURL))
@@ -49,9 +49,9 @@ func processHTTPStrmPlaybackInfo(jsonChain *utils.JsonChain, bsePath string, id
4949
)
5050
msgs = append(msgs, fmt.Sprintf("修改直链播放链接为: %s", directStreamURL))
5151
}
52-
logging.Infof("%s 强制禁止转码%s", id, strings.Join(msgs, ", "))
52+
logging.Infof("%s 强制禁止串流/转码行为,%s", id, strings.Join(msgs, ", "))
5353
} else {
54-
logging.Infof("%s 保持原有转码设置", id)
54+
logging.Infof("%s 保持原有串流/转码行为", id)
5555
}
5656
}
5757

@@ -61,22 +61,21 @@ func processAlistStrmPlaybackInfo(jsonChain *utils.JsonChain, bsePath string, id
6161
logging.Debugf("处理 AlistStrm %s PlaybackInfo 耗时:%s", id, time.Since(startTime))
6262
}()
6363

64-
if !config.AlistStrm.TransCode {
64+
if !config.AlistStrm.Proxy {
6565
jsonChain.Set(
66-
bsePath+"SupportsDirectPlay",
67-
true,
68-
).Set(
6966
bsePath+"SupportsDirectStream",
7067
false,
7168
).Set(
7269
bsePath+"SupportsTranscoding",
7370
false,
7471
).Delete(
7572
bsePath + "TranscodingUrl",
73+
).Delete(
74+
bsePath + "TranscodingContainer",
7675
).Delete(
7776
bsePath + "TranscodingSubProtocol",
7877
).Delete(
79-
bsePath + "TranscodingContainer",
78+
bsePath + "TrancodeLiveStartIndex",
8079
)
8180

8281
var msgs []string
@@ -102,9 +101,9 @@ func processAlistStrmPlaybackInfo(jsonChain *utils.JsonChain, bsePath string, id
102101
container,
103102
)
104103
msgs = append(msgs, fmt.Sprintf("容器为: %s", container))
105-
logging.Infof("%s 强制禁止转码,%s", id, strings.Join(msgs, ", "))
104+
logging.Infof("%s 强制禁止串流/转码行为,%s", id, strings.Join(msgs, ", "))
106105
} else {
107-
logging.Infof("%s 保持原有转码设置", id)
106+
logging.Infof("%s 保持原有串流/转码行为", id)
108107
}
109108

110109
if size == nil {

0 commit comments

Comments
 (0)