]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/pearvideo.py
[ie/crunchyroll] Fix stream extraction (#10005)
[yt-dlp.git] / yt_dlp / extractor / pearvideo.py
index 1d777221cc66942ba9593eda4e02e9b7e4d17aa4..e27e5a7bac5e42e6321a24385fa470b00fa22294 100644 (file)
@@ -1,12 +1,10 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
 
 from .common import InfoExtractor
 from ..utils import (
     qualities,
     unified_timestamp,
+    traverse_obj,
 )
 
 
@@ -39,7 +37,14 @@ def _real_extract(self, url):
         } for mobj in re.finditer(
             r'(?P<id>[a-zA-Z]+)Url\s*=\s*(["\'])(?P<url>(?:https?:)?//.+?)\2',
             webpage)]
-        self._sort_formats(formats)
+        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]
 
         title = self._search_regex(
             (r'<h1[^>]+\bclass=(["\'])video-tt\1[^>]*>(?P<value>[^<]+)',