Skip to content

Commit

Permalink
修改streamlink的http相关参数失效
Browse files Browse the repository at this point in the history
  • Loading branch information
auqhjjqdo committed Dec 27, 2023
1 parent 6335943 commit 865b1e7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions live_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ def get_streamlink(self):
'hls-segment-queue-threshold': 10
})
# 添加streamlink的http相关选项
for arg in ('proxy', 'headers', 'cookies'):
if attr := getattr(self, arg):
# 代理为socks5时,streamlink的代理参数需要改为socks5h,防止部分直播源获取失败
if 'socks' in attr:
attr = attr.replace('://', 'h://')
session.set_option(f'http-{arg}', attr)
if proxy := self.proxy:
# 代理为socks5时,streamlink的代理参数需要改为socks5h,防止部分直播源获取失败
if 'socks' in proxy:
proxy = proxy.replace('://', 'h://')
session.set_option('http-proxy', proxy)
if self.headers:
session.set_option('http-header', self.headers)
if self.cookies:
session.set_option('http-cookie', self.headers)
return session

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

0 comments on commit 865b1e7

Please sign in to comment.