[PearVideo] Add fallback for formats (#3438)

Closes #3425
Authored by: hatienl0i261299
This commit is contained in:
Ha Tien Loi 2022-04-22 20:45:52 +07:00 committed by GitHub
parent 7774db5bf9
commit d14b920c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@ from .common import InfoExtractor
from ..utils import (
qualities,
unified_timestamp,
traverse_obj,
)
@ -36,6 +37,14 @@ class PearVideoIE(InfoExtractor):
} for mobj in re.finditer(
r'(?P<id>[a-zA-Z]+)Url\s*=\s*(["\'])(?P<url>(?: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(