1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
5 from random import random
8 from .common import InfoExtractor
10 compat_urllib_request,
18 class IPrimaIE(InfoExtractor):
19 _VALID_URL = r'https?://play\.iprima\.cz/(?:[^/]+/)*(?P<id>[^?#]+)'
22 'url': 'http://play.iprima.cz/particka/particka-92',
26 'title': 'Partička (92)',
27 'description': 'md5:db00b9bc10ffd26fb148fa6a3a67c40b',
28 'thumbnail': 'http://play.iprima.cz/sites/default/files/image_crops/image_620x349/3/491483_particka-92_image_620x349.jpg',
31 'skip_download': True, # requires rtmpdump
34 'url': 'http://play.iprima.cz/particka/tchibo-particka-jarni-moda',
38 'title': 'Tchibo Partička - Jarní móda',
39 'description': 'md5:db00b9bc10ffd26fb148fa6a3a67c40b',
40 'thumbnail': 're:^http:.*\.jpg$',
43 'skip_download': True, # requires rtmpdump
45 'skip': 'Do not have permission to access this page',
47 'url': 'http://play.iprima.cz/zpravy-ftv-prima-2752015',
48 'only_matching': True,
51 def _real_extract(self, url):
52 mobj = re.match(self._VALID_URL, url)
53 video_id = mobj.group('id')
55 webpage = self._download_webpage(url, video_id)
57 if re.search(r'Nemáte oprávnění přistupovat na tuto stránku\.\s*</div>', webpage):
59 '%s said: You do not have permission to access this page' % self.IE_NAME, expected=True)
62 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
63 (floor(random() * 1073741824), floor(random() * 1073741824))
66 req = compat_urllib_request.Request(player_url)
67 req.add_header('Referer', url)
68 playerpage = self._download_webpage(req, video_id)
70 base_url = ''.join(re.findall(r"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage)[1])
72 zoneGEO = self._html_search_regex(r'"zoneGEO":(.+?),', webpage, 'zoneGEO')
74 base_url = base_url.replace('token', 'token_' + zoneGEO)
77 for format_id in ['lq', 'hq', 'hd']:
78 filename = self._html_search_regex(
79 r'"%s_id":(.+?),' % format_id, webpage, 'filename')
81 if filename == 'null':
84 real_id = self._search_regex(
85 r'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
86 filename, 'real video id')
90 elif format_id == 'hq':
92 elif format_id == 'hd':
94 filename = 'hq/' + filename
97 'format_id': format_id,
100 'play_path': 'mp4:' + filename.replace('"', '')[:-4],
105 self._sort_formats(formats)
109 'title': remove_end(self._og_search_title(webpage), ' | Prima PLAY'),
110 'thumbnail': self._og_search_thumbnail(webpage),
112 'description': self._og_search_description(webpage),