use flake8 to check code

This commit is contained in:
GD-Slime 2023-11-09 17:21:42 +08:00
parent 66db69f511
commit 73324baa2d

View file

@ -31,7 +31,6 @@
srt_subtitles_timecode, srt_subtitles_timecode,
str_or_none, str_or_none,
traverse_obj, traverse_obj,
try_call,
unified_timestamp, unified_timestamp,
unsmuggle_url, unsmuggle_url,
url_or_none, url_or_none,
@ -179,16 +178,15 @@ def _get_episodes_from_season(self, ss_id, url):
note='Downloading season info', query={'season_id': ss_id}, note='Downloading season info', query={'season_id': ss_id},
headers={'Referer': url, **self.geo_verification_headers()}) headers={'Referer': url, **self.geo_verification_headers()})
for entry in traverse_obj(season_info, ( for entry in traverse_obj(season_info, ('result', 'main_section', 'episodes',
'result', 'main_section', 'episodes',
lambda _, v: url_or_none(v['share_url']) and v['id'])): lambda _, v: url_or_none(v['share_url']) and v['id'])):
yield self.url_result(entry['share_url'], BiliBiliBangumiIE, f'ep{entry["id"]}') yield self.url_result(entry['share_url'], BiliBiliBangumiIE, f'ep{entry["id"]}')
def _enc_wbi(self, params: dict, video_id=None): def _enc_wbi(self, params: dict, video_id=None):
if video_id is None: if video_id is None:
video_id = 0 video_id = 0
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)
key_from_url = lambda x: x[x.rfind('/') + 1:].split('.')[0] key_from_url = lambda x: x[x.rfind('/') + 1:].split('.')[0]
img_key = traverse_obj( img_key = traverse_obj(
@ -1381,7 +1379,8 @@ def _perform_login(self, username, password):
public_key = Cryptodome.RSA.importKey(key_data['key']) public_key = Cryptodome.RSA.importKey(key_data['key'])
password_hash = Cryptodome.PKCS1_v1_5.new(public_key).encrypt((key_data['hash'] + password).encode('utf-8')) password_hash = Cryptodome.PKCS1_v1_5.new(public_key).encrypt((key_data['hash'] + password).encode('utf-8'))
login_post = self._download_json( login_post = self._download_json(
'https://passport.bilibili.tv/x/intl/passport-login/web/login/password?lang=en-US', None, data=urlencode_postdata({ 'https://passport.bilibili.tv/x/intl/passport-login/web/login/password?lang=en-US', None,
data=urlencode_postdata({
'username': username, 'username': username,
'password': base64.b64encode(password_hash).decode('ascii'), 'password': base64.b64encode(password_hash).decode('ascii'),
'keep_me': 'true', 'keep_me': 'true',
@ -1567,7 +1566,8 @@ def _extract_video_metadata(self, url, video_id, season_id):
self._search_json(r'window\.__INITIAL_(?:DATA|STATE)__\s*=', webpage, 'preload state', video_id, default={}) self._search_json(r'window\.__INITIAL_(?:DATA|STATE)__\s*=', webpage, 'preload state', video_id, default={})
or self._search_nuxt_data(webpage, video_id, '__initialState', fatal=False, traverse=None)) or self._search_nuxt_data(webpage, video_id, '__initialState', fatal=False, traverse=None))
video_data = traverse_obj( video_data = traverse_obj(
initial_data, ('OgvVideo', 'epDetail'), ('UgcVideo', 'videoData'), ('ugc', 'archive'), expected_type=dict) or {} initial_data, ('OgvVideo', 'epDetail'), ('UgcVideo', 'videoData'), ('ugc', 'archive'),
expected_type=dict) or {}
if season_id and not video_data: if season_id and not video_data:
# Non-Bstation layout, read through episode list # Non-Bstation layout, read through episode list
@ -1720,7 +1720,8 @@ def _entries(self, series_id):
def _real_extract(self, url): def _real_extract(self, url):
series_id = self._match_id(url) series_id = self._match_id(url)
series_info = self._call_api(f'/web/v2/ogv/play/season_info?season_id={series_id}&platform=web', series_id).get('season') or {} series_info = self._call_api(f'/web/v2/ogv/play/season_info?season_id={series_id}&platform=web', series_id).get(
'season') or {}
return self.playlist_result( return self.playlist_result(
self._entries(series_id), series_id, series_info.get('title'), series_info.get('description'), self._entries(series_id), series_id, series_info.get('title'), series_info.get('description'),
categories=traverse_obj(series_info, ('styles', ..., 'title'), expected_type=str_or_none), categories=traverse_obj(series_info, ('styles', ..., 'title'), expected_type=str_or_none),