diff --git a/yt_dlp/extractor/pialive.py b/yt_dlp/extractor/pialive.py index 85756b67d0..c85c4acf9d 100644 --- a/yt_dlp/extractor/pialive.py +++ b/yt_dlp/extractor/pialive.py @@ -1,5 +1,5 @@ from .common import InfoExtractor -from ..utils import extract_attributes, multipart_encode, traverse_obj +from ..utils import extract_attributes, multipart_encode, traverse_obj, url_or_none class PiaLiveIE(InfoExtractor): @@ -15,9 +15,10 @@ class PiaLiveIE(InfoExtractor): 'display_id': '2431867_001', 'title': 'こながめでたい日2024の視聴ページ | PIA LIVE STREAM(ぴあライブストリーム)', 'live_status': 'was_live', - 'comment_count': 1000, + 'comment_count': int, }, 'params': { + 'getcomments': True, 'skip_download': True, 'ignore_no_formats_error': True, }, @@ -29,67 +30,67 @@ class PiaLiveIE(InfoExtractor): 'display_id': '2431867_002', 'title': 'こながめでたい日2024の視聴ページ | PIA LIVE STREAM(ぴあライブストリーム)', 'live_status': 'was_live', - 'comment_count': 1000, + 'comment_count': int, }, 'params': { + 'getcomments': True, 'skip_download': True, 'ignore_no_formats_error': True, }, }, ] + def _extract_vars(self, variable, html): + return self._search_regex( + rf'(?:var|const)\s+{variable}\s*=\s*(["\'])(?P(?:(?!\1).)+)\1', + html, 'variable', group='value', default=None) + def _real_extract(self, url): video_key = self._match_id(url) webpage = self._download_webpage(url, video_key) - program_code = self._search_regex(r"const programCode = '(.*?)';", webpage, 'program code') + + program_code = self._extract_vars('programCode', webpage) + article_code = self._extract_vars('articleCode', webpage) prod_configure = self._download_webpage( - self.PLAYER_ROOT_URL + self._search_regex(r'