From a75a02ad2a96423f3bf87ba7310b3603bf00cb85 Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:47:15 +0800 Subject: [PATCH] [ie/pialive] Follow your steps (#1) * [ie/pialive] Support detecting upcoming and ended live events * Pack API arguments * fix UnboundLocalError for "chat_room_url" * extract video_id from query string by "parse_qs()" * Fix tests --- yt_dlp/extractor/pialive.py | 50 +++++++++++++++++++++++++----- yt_dlp/extractor/piaulizaportal.py | 5 ++- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/pialive.py b/yt_dlp/extractor/pialive.py index 69b484fd5f..013d19aa4d 100644 --- a/yt_dlp/extractor/pialive.py +++ b/yt_dlp/extractor/pialive.py @@ -1,5 +1,14 @@ from .common import InfoExtractor -from ..utils import extract_attributes, multipart_encode, url_or_none +from ..utils import ( + ExtractorError, + clean_html, + extract_attributes, + get_element_by_class, + get_element_html_by_class, + multipart_encode, + unified_timestamp, + url_or_none, +) from ..utils.traversal import traverse_obj @@ -24,6 +33,7 @@ class PiaLiveIE(InfoExtractor): 'skip_download': True, 'ignore_no_formats_error': True, }, + 'skip': 'The video is no longer available', }, { 'url': 'https://player.pia-live.jp/stream/4JagFBEIM14s_hK9aXHKf3k3F3bY5eoHFQxu68TC6krJdu0GVBVbVy01IwpJ6J3qBEm3d9TCTt1d0eWpsZGj7DrOjVOmS7GAWGwyscMgiThopJvzgWC4H5b-7XQjAfRZ', @@ -39,6 +49,7 @@ class PiaLiveIE(InfoExtractor): 'skip_download': True, 'ignore_no_formats_error': True, }, + 'skip': 'The video is no longer available', }, ] @@ -53,28 +64,51 @@ class PiaLiveIE(InfoExtractor): program_code = self._extract_vars('programCode', webpage) article_code = self._extract_vars('articleCode', webpage) + title = self._html_extract_title(webpage) + + if get_element_html_by_class('play-end', webpage): + raise ExtractorError('The video is no longer available', expected=True, video_id=program_code) + + if start_info := clean_html(get_element_by_class('play-waiting__date', webpage)): + date, time = self._search_regex( + r'(?P\d{4}/\d{1,2}/\d{1,2})\([月火水木金土日]\)(?P