1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-24 04:42:52 +08:00

additional info and better regexes

This commit is contained in:
Ales Jirasek 2018-10-11 01:14:35 +02:00
parent 4bcc6c372f
commit 53b12fac9d

View File

@ -2,6 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import parse_duration
class MallTVIE(InfoExtractor): class MallTVIE(InfoExtractor):
@ -22,7 +23,7 @@ class MallTVIE(InfoExtractor):
'nimi nakládá. Objem dotací pro neziskovky ' 'nimi nakládá. Objem dotací pro neziskovky '
'roste, ale opravdu jsou tyto organizace ' 'roste, ale opravdu jsou tyto organizace '
'„pijavice", jak o nich hovoří And') '„pijavice", jak o nich hovoří And')
} },
}, },
{ {
'url': ('https://www.mall.tv/kdo-to-plati/18-miliard-pro-neziskovky' 'url': ('https://www.mall.tv/kdo-to-plati/18-miliard-pro-neziskovky'
@ -46,22 +47,29 @@ class MallTVIE(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_LD_RE = (r'(?is)<script[^>]+type=([\"\'])?application/ld\+json>.*'
self.report_extraction(video_id) '(?P<json_ld>{.+}).*</script>')
json_ld = self._search_regex(JSON_LD_RE, webpage, 'JSON_LD',
group='json_ld')
if not json_ld:
info = {}
else:
info = self._json_ld(json_ld, video_id)
format_url = self._html_search_regex( format_url = self._html_search_regex(
r'<source src=(.+index)\s', r'<source src=([\"\'])?(.+index)\s',
webpage, webpage,
'm3u8 URL') 'm3u8 URL')
formats = self._extract_m3u8_formats(format_url+'.m3u8', formats = self._extract_m3u8_formats(format_url+'.m3u8',
video_id, 'mp4') video_id, 'mp4')
self._sort_formats(formats) self._sort_formats(formats)
title = info.get('title', self._og_search_title(webpage, fatal=False))
thumbnail = info.get('thumbnailUrl', self._og_search_thumbnail(webpage))
return { return {
'id': video_id, 'id': video_id,
'title': self._og_search_title(webpage), 'title': title,
'thumbnail': self._og_search_thumbnail(webpage), 'thumbnail': thumbnail,
'description': self._og_search_description(webpage), 'description': self._og_search_description(webpage),
'title': self._og_search_title(webpage), 'duration': parse_duration(info.get('duration')),
'formats': formats 'formats': formats
} }