]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/malltv.py
debian/control: Mark my GitHub trees as the preferred repos.
[youtubedl] / youtube_dl / extractor / malltv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import merge_dicts
8
9
10 class MallTVIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?mall\.tv/(?:[^/]+/)*(?P<id>[^/?#&]+)'
12 _TESTS = [{
13 'url': 'https://www.mall.tv/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
14 'md5': '1c4a37f080e1f3023103a7b43458e518',
15 'info_dict': {
16 'id': 't0zzt0',
17 'display_id': '18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
18 'ext': 'mp4',
19 'title': '18 miliard pro neziskovky. Opravdu jsou sportovci nebo Člověk v tísni pijavice?',
20 'description': 'md5:25fc0ec42a72ba602b602c683fa29deb',
21 'duration': 216,
22 'timestamp': 1538870400,
23 'upload_date': '20181007',
24 'view_count': int,
25 }
26 }, {
27 'url': 'https://www.mall.tv/kdo-to-plati/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
28 'only_matching': True,
29 }]
30
31 def _real_extract(self, url):
32 display_id = self._match_id(url)
33
34 webpage = self._download_webpage(
35 url, display_id, headers=self.geo_verification_headers())
36
37 SOURCE_RE = r'(<source[^>]+\bsrc=(?:(["\'])(?:(?!\2).)+|[^\s]+)/(?P<id>[\da-z]+)/index)\b'
38 video_id = self._search_regex(
39 SOURCE_RE, webpage, 'video id', group='id')
40
41 media = self._parse_html5_media_entries(
42 url, re.sub(SOURCE_RE, r'\1.m3u8', webpage), video_id,
43 m3u8_id='hls', m3u8_entry_protocol='m3u8_native')[0]
44
45 info = self._search_json_ld(webpage, video_id, default={})
46
47 return merge_dicts(media, info, {
48 'id': video_id,
49 'display_id': display_id,
50 'title': self._og_search_title(webpage, default=None) or display_id,
51 'description': self._og_search_description(webpage, default=None),
52 'thumbnail': self._og_search_thumbnail(webpage, default=None),
53 })