Skip to content

Commit 37f43bf

Browse files
committed
修复streamlink的http相关参数失效
1 parent 6335943 commit 37f43bf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

live_recorder.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ def get_streamlink(self):
117117
'hls-segment-queue-threshold': 10
118118
})
119119
# 添加streamlink的http相关选项
120-
for arg in ('proxy', 'headers', 'cookies'):
121-
if attr := getattr(self, arg):
122-
# 代理为socks5时,streamlink的代理参数需要改为socks5h,防止部分直播源获取失败
123-
if 'socks' in attr:
124-
attr = attr.replace('://', 'h://')
125-
session.set_option(f'http-{arg}', attr)
120+
if proxy := self.proxy:
121+
# 代理为socks5时,streamlink的代理参数需要改为socks5h,防止部分直播源获取失败
122+
if 'socks' in proxy:
123+
proxy = proxy.replace('://', 'h://')
124+
session.set_option('http-proxy', proxy)
125+
if self.headers:
126+
session.set_option('http-header', self.headers)
127+
if self.cookies:
128+
session.set_option('http-cookie', self.headers)
126129
return session
127130

128131
def run_record(self, stream: Union[StreamIO, HTTPStream], url, title, format):

0 commit comments

Comments
 (0)