From 77ed5d5bf9ad4a828a80aecbcb94e6d6b86bacca Mon Sep 17 00:00:00 2001 From: GD-Slime <1289744583@qq.com> Date: Thu, 9 Nov 2023 19:39:14 +0800 Subject: [PATCH] fix some bugs in review --- yt_dlp/extractor/bilibili.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py index c577611a2..93f95c69a 100644 --- a/yt_dlp/extractor/bilibili.py +++ b/yt_dlp/extractor/bilibili.py @@ -189,9 +189,9 @@ def _enc_wbi(self, params: dict, video_id=None): session_data = self._download_json('https://api.bilibili.com/x/web-interface/nav', video_id, note='wbi signature...', fatal=False) - key_from_url = lambda x: x.rpartition('/')[2].partition('.')[0] - lookup = traverse_obj( - session_data, ('data', 'wbi_img', ('img_url', 'sub_url'), {key_from_url}, ...)) + lookup = traverse_obj(session_data, ( + 'data', 'wbi_img', ('img_url', 'sub_url'), + {lambda x: x.rpartition('/')[2].partition('.')[0]})) mixin_key_enc_tab = [ 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, @@ -199,10 +199,11 @@ def _enc_wbi(self, params: dict, video_id=None): 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52 ] - mixin_key = ''.join(lookup[i] for i in mixin_key_enc_tab)[:32] + mixin_key = ''.join((lookup[0] + lookup[1])[i] for i in mixin_key_enc_tab)[:32] + params['wts'] = round(time.time()) params = { - k: ''.join(filter('!\'()*'.__contains__, str(v))) + k: ''.join(filter(lambda char: char not in "!'()*", str(v))) for k, v in sorted(params.items()) } query = urllib.parse.urlencode(params)