2 from __future__ import unicode_literals
4 from .common import InfoExtractor
17 class PlaytvakIE(InfoExtractor):
18 IE_DESC = 'Playtvak.cz, iDNES.cz and Lidovky.cz'
19 _VALID_URL = r'https?://(?:.+?\.)?(?:playtvak|idnes|lidovky|metro)\.cz/.*\?(?:c|idvideo)=(?P<id>[^&]+)'
21 'url': 'http://www.playtvak.cz/vyzente-vosy-a-srsne-ze-zahrady-dn5-/hodinovy-manzel.aspx?c=A150730_150323_hodinovy-manzel_kuko',
22 'md5': '4525ae312c324b4be2f4603cc78ceb4a',
24 'id': 'A150730_150323_hodinovy-manzel_kuko',
26 'title': 'Vyžeňte vosy a sršně ze zahrady',
27 'description': 'md5:f93d398691044d303bc4a3de62f3e976',
28 'thumbnail': 're:(?i)^https?://.*\.(?:jpg|png)$',
30 'timestamp': 1438732860,
31 'upload_date': '20150805',
34 }, { # live video test
35 'url': 'http://slowtv.playtvak.cz/planespotting-0pr-/planespotting.aspx?c=A150624_164934_planespotting_cat',
37 'id': 'A150624_164934_planespotting_cat',
39 'title': 're:^Přímý přenos iDNES.cz [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
40 'description': 'Sledujte provoz na ranveji Letiště Václava Havla v Praze',
41 'thumbnail': 're:(?i)^https?://.*\.(?:jpg|png)$',
45 'skip_download': True, # requires rtmpdump
48 'url': 'http://zpravy.idnes.cz/pes-zavreny-v-aute-rozbijeni-okynek-v-aute-fj5-/domaci.aspx?c=A150809_104116_domaci_pku',
49 'md5': '819832ba33cd7016e58a6658577fe289',
51 'id': 'A150809_104116_domaci_pku',
53 'title': 'Zavřeli jsme mraženou pizzu do auta. Upekla se',
54 'description': 'md5:01e73f02329e2e5760bd5eed4d42e3c2',
55 'thumbnail': 're:(?i)^https?://.*\.(?:jpg|png)$',
57 'timestamp': 1438969140,
58 'upload_date': '20150807',
62 'url': 'http://www.lidovky.cz/dalsi-demonstrace-v-praze-o-migraci-duq-/video.aspx?c=A150808_214044_ln-video_ELE',
63 'md5': 'c7209ac4ba9d234d4ad5bab7485bcee8',
65 'id': 'A150808_214044_ln-video_ELE',
67 'title': 'Táhni! Demonstrace proti imigrantům budila emoce',
68 'description': 'md5:97c81d589a9491fbfa323c9fa3cca72c',
69 'thumbnail': 're:(?i)^https?://.*\.(?:jpg|png)$',
70 'timestamp': 1439052180,
71 'upload_date': '20150808',
75 'url': 'http://www.playtvak.cz/embed.aspx?idvideo=V150729_141549_play-porad_kuko',
76 'only_matching': True,
79 def _real_extract(self, url):
80 video_id = self._match_id(url)
82 webpage = self._download_webpage(url, video_id)
84 info_url = self._html_search_regex(
85 r'Misc\.videoFLV\(\s*{\s*data\s*:\s*"([^"]+)"', webpage, 'info url')
87 parsed_url = compat_urlparse.urlparse(info_url)
89 qs = compat_urlparse.parse_qs(parsed_url.query)
95 info_url = compat_urlparse.urlunparse(
96 parsed_url._replace(query = compat_urllib_parse.urlencode(qs, True)))
98 json_info = self._download_json(
100 transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1])
103 for i in json_info['items']:
104 if i.get('type') == 'video' or i.get('type') == 'stream':
108 raise ExtractorError('No suitable stream found')
110 quality = qualities(['low', 'middle', 'high'])
113 for fmt in item['video']:
114 video_url = fmt.get('file')
118 format_ = fmt['format']
119 format_id = '%s_%s' % (format_, fmt['quality'])
122 if format_ in ['mp4', 'webm']:
124 elif format_ == 'rtmp':
126 elif format_ == 'apple':
128 # Some streams have mp3 audio which does not play
129 # well with ffmpeg filter aac_adtstoasc
131 elif format_ == 'adobe': # f4m manifest fails with 404 in 80% of requests
133 else: # Other formats not supported yet
139 'format_id': format_id,
140 'quality': quality(fmt.get('quality')),
141 'preference': preference,
143 self._sort_formats(formats)
145 title = item['title']
146 is_live = item['type'] == 'stream'
148 title = self._live_title(title)
152 duration = int_or_none(item.get('length'))
153 timestamp = item.get('published')
155 timestamp = parse_iso8601(timestamp[:-5])
160 'description': self._og_search_description(webpage),
161 'thumbnail': item.get('image'),
162 'duration': duration,
163 'timestamp': timestamp,