Accept some suggestions in code review

This commit is contained in:
GD-Slime 2023-11-09 21:06:42 +08:00
parent 77ed5d5bf9
commit 7c3cfab73a

View file

@ -66,6 +66,7 @@ def extract_formats(self, play_info, is_dash=True):
formats.append({ formats.append({
'fragments': segments, 'fragments': segments,
'url': traverse_obj(video[0], 'url'), 'url': traverse_obj(video[0], 'url'),
'protocol': 'http_dash_segments',
'format_id': str(qn), 'format_id': str(qn),
'duration': float_or_none(play_info.get('timelength'), scale=1000), 'duration': float_or_none(play_info.get('timelength'), scale=1000),
'resolution': format_names.get(qn), 'resolution': format_names.get(qn),
@ -189,9 +190,9 @@ def _enc_wbi(self, params: dict, video_id=None):
session_data = self._download_json('https://api.bilibili.com/x/web-interface/nav', session_data = self._download_json('https://api.bilibili.com/x/web-interface/nav',
video_id, note='wbi signature...', fatal=False) video_id, note='wbi signature...', fatal=False)
lookup = traverse_obj(session_data, ( lookup = ''.join(traverse_obj(session_data, (
'data', 'wbi_img', ('img_url', 'sub_url'), 'data', 'wbi_img', ('img_url', 'sub_url'),
{lambda x: x.rpartition('/')[2].partition('.')[0]})) {lambda x: x.rpartition('/')[2].partition('.')[0]})))
mixin_key_enc_tab = [ mixin_key_enc_tab = [
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
@ -199,7 +200,7 @@ 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, 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 36, 20, 34, 44, 52
] ]
mixin_key = ''.join((lookup[0] + lookup[1])[i] for i in mixin_key_enc_tab)[:32] mixin_key = ''.join(lookup[i] for i in mixin_key_enc_tab)[:32]
params['wts'] = round(time.time()) params['wts'] = round(time.time())
params = { params = {