From b61ff5ed0882cac78bea05107dc27b93865bced8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=81=A24=2E435km/s?= <54017765+CoolZxp@users.noreply.github.com> Date: Tue, 6 May 2025 11:22:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8DTwitCasting,TwitCasti?= =?UTF-8?q?ng=E6=B7=BB=E5=8A=A0Cookie,TwitCasting=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=BB=E8=B4=A8=E9=80=89=E6=8B=A9=20(#1282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 适配TwitCasting,TwitCasting添加Cookie,TwitCasting添加画质选择 * Update __init__.py --------- Co-authored-by: ForgQi <34411314+ForgQi@users.noreply.github.com> --- app/ui/plugins/twitcasting.tsx | 35 ++++++++++++++ biliup/__init__.py | 2 +- biliup/plugins/twitcasting.py | 88 +++++++++++++++++++++++----------- 3 files changed, 97 insertions(+), 28 deletions(-) diff --git a/app/ui/plugins/twitcasting.tsx b/app/ui/plugins/twitcasting.tsx index 9c331d2..6688023 100644 --- a/app/ui/plugins/twitcasting.tsx +++ b/app/ui/plugins/twitcasting.tsx @@ -23,6 +23,25 @@ const TwitCasting: React.FC = props => { return ( <> + + TwitCasting自选画质,没有选中的画质则会自动选择更低级别清晰度,如更低级别画质依旧没有则选择最清晰的。 + + } + label="画质等级(twitcasting_quality)" + style={{ width: '100%' }} + fieldStyle={{ + alignSelf: 'stretch', + padding: 0, + }} + showClear={true} + > + 高画质(high) + 中画质(medium) + 低画质(low) + = props => { padding: 0, }} /> + + Cookie格式: +
+ tc_id=xxxxxxx; tc_ss=xxxxxxx; + + } + label="TwitCasting Cookie(twitcasting_cookie)" + style={{ width: '100%' }} + fieldStyle={{ + alignSelf: 'stretch', + padding: 0, + }} + /> {stream_info}") + return False + + stream_url = None + quality_levels = ["high", "medium", "low"] + streams = stream_info["tc-hls"]["streams"] + if self.twitcasting_quality: + quality_levels_filter = quality_levels[quality_levels.index(self.twitcasting_quality):] + for quality_level in quality_levels_filter: + if quality_level in streams: + stream_url = streams[quality_level] + break + if not stream_url: + for quality_level in quality_levels: + if quality_level in streams: + stream_url = streams[quality_level] + break + if not stream_url: + stream_url = next(iter(streams.values())) + + if not stream_url: + logger.error(f"{Twitcasting.__name__}: {self.url}: 未查找到直播流 => {stream_info}") + return False + + self.raw_stream_url = stream_url + return True def danmaku_init(self): if self.twitcasting_danmaku: self.danmaku = DanmakuClient(self.url, self.gen_download_filename(), { - 'movie_id': self.movie_id, + 'movie_id': self._movie_id, 'password': self.twitcasting_password, })