mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-27 13:15:04 +00:00
[ie/pialive] fix comment extraction
Authored by: bashonly
This commit is contained in:
parent
67a7194547
commit
d308f6c36e
@ -6,6 +6,7 @@ from ..utils import (
|
|||||||
get_element_by_class,
|
get_element_by_class,
|
||||||
get_element_html_by_class,
|
get_element_html_by_class,
|
||||||
multipart_encode,
|
multipart_encode,
|
||||||
|
str_or_none,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
@ -112,15 +113,17 @@ class PiaLiveIE(InfoExtractor):
|
|||||||
def _get_comments(self, video_id, chat_room_url):
|
def _get_comments(self, video_id, chat_room_url):
|
||||||
if not chat_room_url:
|
if not chat_room_url:
|
||||||
return
|
return
|
||||||
if comment_page := self._download_webpage(
|
comment_page = self._download_webpage(
|
||||||
chat_room_url, video_id, headers={'Referer': 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):
|
note='Fetching comment page', errnote='Unable to fetch comment page', fatal=False)
|
||||||
|
if not comment_page:
|
||||||
|
return
|
||||||
yield from traverse_obj(self._search_json(
|
yield from traverse_obj(self._search_json(
|
||||||
r'var\s+_history\s*=', comment_page, 'comment list',
|
r'var\s+_history\s*=', comment_page, 'comment list',
|
||||||
video_id, contains_pattern=r'\[(?s:.+)\]', fatal=False), (..., {
|
video_id, contains_pattern=r'\[(?s:.+)\]', fatal=False), (..., {
|
||||||
'timestamp': 0,
|
'timestamp': (0, {int}),
|
||||||
'author_is_uploader': (1, {lambda x: x == 2}),
|
'author_is_uploader': (1, {lambda x: x == 2}),
|
||||||
'author': 2,
|
'author': (2, {str}),
|
||||||
'text': 3,
|
'text': (3, {str}),
|
||||||
'id': 4,
|
'id': (4, {str_or_none}),
|
||||||
}))
|
}))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user