1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
5 from random import random
8 from .common import InfoExtractor
10 compat_urllib_request,
15 class IPrimaIE(InfoExtractor):
16 _VALID_URL = r'https?://play\.iprima\.cz/[^?#]+/(?P<id>[^?#]+)'
19 'url': 'http://play.iprima.cz/particka/particka-92',
23 'title': 'Partička (92)',
24 'description': 'md5:3740fda51464da35a2d4d0670b8e4fd6',
25 'thumbnail': 'http://play.iprima.cz/sites/default/files/image_crops/image_620x349/3/491483_particka-92_image_620x349.jpg',
28 'skip_download': True, # requires rtmpdump
31 'url': 'http://play.iprima.cz/particka/tchibo-particka-jarni-moda',
35 'title': 'Tchibo Partička - Jarní móda',
36 'description': 'md5:589f8f59f414220621ff8882eb3ce7be',
37 'thumbnail': 're:^http:.*\.jpg$',
40 'skip_download': True, # requires rtmpdump
44 def _real_extract(self, url):
45 mobj = re.match(self._VALID_URL, url)
46 video_id = mobj.group('id')
48 webpage = self._download_webpage(url, video_id)
50 if re.search(r'Nemáte oprávnění přistupovat na tuto stránku.\s*</div>', webpage):
52 '%s said: You do not have permission to access this page' % self.IE_NAME, expected=True)
55 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
56 (floor(random()*1073741824), floor(random()*1073741824))
59 req = compat_urllib_request.Request(player_url)
60 req.add_header('Referer', url)
61 playerpage = self._download_webpage(req, video_id)
63 base_url = ''.join(re.findall(r"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage)[1])
65 zoneGEO = self._html_search_regex(r'"zoneGEO":(.+?),', webpage, 'zoneGEO')
67 base_url = base_url.replace('token', 'token_' + zoneGEO)
70 for format_id in ['lq', 'hq', 'hd']:
71 filename = self._html_search_regex(
72 r'"%s_id":(.+?),' % format_id, webpage, 'filename')
74 if filename == 'null':
77 real_id = self._search_regex(
78 r'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
79 filename, 'real video id')
83 elif format_id == 'hq':
85 elif format_id == 'hd':
87 filename = 'hq/' + filename
90 'format_id': format_id,
93 'play_path': 'mp4:' + filename.replace('"', '')[:-4],
98 self._sort_formats(formats)
102 'title': self._og_search_title(webpage),
103 'thumbnail': self._og_search_thumbnail(webpage),
105 'description': self._og_search_description(webpage),