mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 17:08:32 +00:00
Apply suggestions from code review
This commit is contained in:
parent
30c4364c19
commit
7ca024bc35
@ -14,8 +14,8 @@ class NiconicoLiveFD(FileDownloader):
|
||||
|
||||
def real_download(self, filename, info_dict):
|
||||
video_id = info_dict['id']
|
||||
quality, ws_extractor, ws_url = map(
|
||||
info_dict['downloader_options'].get, ('max_quality', 'ws', 'ws_url'))
|
||||
opts = info_dict['downloader_options']
|
||||
quality, ws_extractor, ws_url = opts['max_quality'], opts['ws'], opts['ws_url']
|
||||
dl = FFmpegFD(self.ydl, self.params or {})
|
||||
|
||||
new_info_dict = info_dict.copy()
|
||||
@ -76,7 +76,7 @@ def ws_main():
|
||||
return
|
||||
except BaseException as e:
|
||||
self.to_screen(
|
||||
f'[niconico:live] {video_id}: Connection error occured, reconnecting after 10 seconds: {str_or_none(e)}')
|
||||
f'[niconico:live] {video_id}: Connection error occured, reconnecting after 10 seconds: {e}')
|
||||
time.sleep(10)
|
||||
continue
|
||||
finally:
|
||||
|
@ -754,7 +754,6 @@ def _real_extract(self, url):
|
||||
class NiconicoLiveIE(NiconicoBaseIE):
|
||||
IE_NAME = 'niconico:live'
|
||||
IE_DESC = 'ニコニコ生放送'
|
||||
|
||||
_VALID_URL = r'https?://(?:sp\.)?live2?\.nicovideo\.jp/(?:watch|gate)/(?P<id>lv\d+)'
|
||||
_TESTS = [{
|
||||
'note': 'this test case includes invisible characters for title, pasting them as-is',
|
||||
@ -787,17 +786,13 @@ class NiconicoLiveIE(NiconicoBaseIE):
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_id, expected_status=404)
|
||||
if err_msg := traverse_obj(webpage, (
|
||||
{find_element(cls='message')}, {clean_html},
|
||||
)):
|
||||
if err_msg := traverse_obj(webpage, ({find_element(cls='message')}, {clean_html})):
|
||||
raise ExtractorError(err_msg, expected=True)
|
||||
|
||||
embedded_data = traverse_obj(webpage, (
|
||||
{find_element(tag='script', id='embedded-data', html=True)},
|
||||
{extract_attributes}, 'data-props', {json.loads},
|
||||
))
|
||||
frontend_id = traverse_obj(embedded_data, (
|
||||
'site', 'frontendId', {str_or_none}), default='9')
|
||||
{extract_attributes}, 'data-props', {json.loads}))
|
||||
frontend_id = traverse_obj(embedded_data, ('site', 'frontendId', {str_or_none}), default='9')
|
||||
|
||||
if not (ws_url := traverse_obj(embedded_data, (
|
||||
'site', 'relive', 'webSocketUrl', {url_or_none},
|
||||
@ -853,7 +848,7 @@ def _real_extract(self, url):
|
||||
title = traverse_obj(embedded_data, ('program', 'title')) or self._html_search_meta(
|
||||
('og:title', 'twitter:title'), webpage, 'live title', fatal=False)
|
||||
|
||||
raw_thumbs = traverse_obj(embedded_data, ('program', 'thumbnail', {dict}), default={})
|
||||
raw_thumbs = traverse_obj(embedded_data, ('program', 'thumbnail', {dict})) or {}
|
||||
thumbnails = []
|
||||
for name, value in raw_thumbs.items():
|
||||
if not isinstance(value, dict):
|
||||
|
Loading…
Reference in New Issue
Block a user