Apply suggestions from code review

Co-authored-by: sepro <sepro@sepr0.com>
This commit is contained in:
ChocoLZS 2024-10-01 16:31:47 +08:00 committed by GitHub
parent a75a02ad2a
commit b42637c619
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -97,13 +97,12 @@ def _real_extract(self, url):
player_tag_list = self._download_json(
f'{self.PIA_LIVE_API_URL}/perf/player-tag-list/{program_code}', **api_kwargs,
note='Fetching player tag list', errnote='Unable to fetch player tag list')
chat_room_url = None
if self.get_param('getcomments'):
chat_room_url = traverse_obj(self._download_json(
f'{self.PIA_LIVE_API_URL}/perf/chat-tag-list/{program_code}/{article_code}', **api_kwargs,
note='Fetching chat info', errnote='Unable to fetch chat info', fatal=False),
('data', 'chat_one_tag', {extract_attributes}, 'src', {url_or_none}))
else:
chat_room_url = None
return self.url_result(
extract_attributes(player_tag_list['data']['movie_one_tag'])['src'], url_transparent=True,
@ -114,7 +113,7 @@ def _get_comments(self, video_id, chat_room_url):
if not chat_room_url:
return
if comment_page := self._download_webpage(
chat_room_url, video_id, headers={'Referer': f'{self.PLAYER_ROOT_URL}'},
chat_room_url, video_id, headers={'Referer': self.PLAYER_ROOT_URL},
note='Fetching comment page', errnote='Unable to fetch comment page', fatal=False):
yield from traverse_obj(self._search_json(
r'var\s+_history\s*=', comment_page, 'comment list',

View file

@ -103,5 +103,5 @@ def _real_extract(self, url):
r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"',
webpage, 'player data url')
return self.url_result(
player_data_url, url_transparent=True,
player_data_url, PIAULIZAPortalAPIIE, url_transparent=True,
display_id=video_id, video_title=self._html_extract_title(webpage))