[earthcams] Add new extractor per #19293
This commit is contained in:
parent
cf2b0fe00e
commit
7b392e10fb
@ -4,6 +4,9 @@ from __future__ import unicode_literals
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
urljoin,
|
urljoin,
|
||||||
|
int_or_none,
|
||||||
|
url_or_none,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -25,25 +28,23 @@ class EarthCamsIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
json_str = self._search_regex(r'var\s+json_base\s*=\s*(?P<jstr>{\s*"cam"\s*:\s*{.*}.*});', webpage, 'jstr')
|
||||||
json_str = self._search_regex(r'var\sjson_base\s*=\s*(?P<jstr>{.*});', webpage, 'jstr')
|
|
||||||
json_base = self._parse_json(json_str, video_id)
|
json_base = self._parse_json(json_str, video_id)
|
||||||
|
video_info = try_get(json_base, lambda x: x['cam'][video_id], dict) or {}
|
||||||
title = json_base["cam"][video_id]["long_title"]
|
title = video_info.get("long_title")
|
||||||
description = json_base["cam"][video_id]["description"]
|
description = video_info.get("description")
|
||||||
thumbnail = json_base["cam"][video_id]["thumbimage"]
|
thumbnail = video_info.get("thumbimage")
|
||||||
view_count = int(json_base["cam"][video_id]["streamviews"])
|
view_count = int_or_none(video_info.get("streamviews"))
|
||||||
|
domain = video_info.get("html5_streamingdomain")
|
||||||
domain = json_base["cam"][video_id]["html5_streamingdomain"]
|
path = video_info.get("html5_streampath")
|
||||||
path = json_base["cam"][video_id]["html5_streampath"]
|
|
||||||
m3u8_url = urljoin(domain, path)
|
m3u8_url = urljoin(domain, path)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', 'm3u8_native'),
|
'formats': self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', 'm3u8_native'),
|
||||||
'title': title,
|
'title': title or self._og_search_title(webpage),
|
||||||
'description': description,
|
'description': description or self._og_search_description(webpage),
|
||||||
'view_count': view_count,
|
'view_count': view_count,
|
||||||
'is_live': True,
|
'is_live': True,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': url_or_none(thumbnail),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user