From d14b920c330b00ca50a66bf471b9f901ebc16212 Mon Sep 17 00:00:00 2001 From: Ha Tien Loi Date: Fri, 22 Apr 2022 20:45:52 +0700 Subject: [PATCH] [PearVideo] Add fallback for formats (#3438) Closes #3425 Authored by: hatienl0i261299 --- yt_dlp/extractor/pearvideo.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yt_dlp/extractor/pearvideo.py b/yt_dlp/extractor/pearvideo.py index d552e0966..e76305acd 100644 --- a/yt_dlp/extractor/pearvideo.py +++ b/yt_dlp/extractor/pearvideo.py @@ -4,6 +4,7 @@ from ..utils import ( qualities, unified_timestamp, + traverse_obj, ) @@ -36,6 +37,14 @@ def _real_extract(self, url): } for mobj in re.finditer( r'(?P[a-zA-Z]+)Url\s*=\s*(["\'])(?P(?:https?:)?//.+?)\2', webpage)] + if not formats: + info = self._download_json( + 'https://www.pearvideo.com/videoStatus.jsp', video_id=video_id, + query={'contId': video_id}, headers={'Referer': url}) + formats = [{ + 'format_id': k, + 'url': v.replace(info['systemTime'], f'cont-{video_id}') if k == 'srcUrl' else v + } for k, v in traverse_obj(info, ('videoInfo', 'videos'), default={}).items() if v] self._sort_formats(formats) title = self._search_regex(