mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-09 02:58:49 +00:00
Improve fallback
This commit is contained in:
parent
cf4a829c13
commit
e8aca87278
@ -1,7 +1,6 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
from ..utils import (
|
||||
@ -10,8 +9,10 @@ from ..utils import (
|
||||
merge_dicts,
|
||||
NO_DEFAULT,
|
||||
RegexNotFoundError,
|
||||
try_get,
|
||||
url_or_none,
|
||||
)
|
||||
from ..compat import compat_str
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
||||
@ -82,9 +83,9 @@ class MegaCartoonsIE(InfoExtractor):
|
||||
|
||||
if 'url' not in info or 'thumbnail' not in info:
|
||||
# Video data is stored in a json -> extract it from the raw html
|
||||
url_json = json.loads(self._html_search_regex(r'<div.*data-item=["/\'](?P<videourls>{.*})["/\'].*>', webpage, 'videourls'))
|
||||
url_json = self._parse_json(self._html_search_regex(r'''<div\b[^>]+\bdata-item\s*=\s*(["'])(?P<videourls>\{.*})\1''', webpage, 'videourls', group='videourls', default='{}'), video_id, fatal=False)) or {}
|
||||
|
||||
video_url = url_or_none(url_json.get('sources')[0].get('src') or self._og_search_video_url(webpage)) # Get the video url
|
||||
video_url = url_or_none(try_get(url_json, lambda x: x['sources'][0]['src'], compat_str) or self._og_search_video_url(webpage)) # Get the video url
|
||||
video_thumbnail = url_or_none(url_json.get('splash') or self._og_search_thumbnail(webpage)) # Get the thumbnail
|
||||
info = merge_dicts(info, {
|
||||
'url': video_url,
|
||||
|
Loading…
Reference in New Issue
Block a user