1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
5 from random import random
8 from .common import InfoExtractor
9 from ..utils import compat_urllib_request
12 class IPrimaIE(InfoExtractor):
13 _VALID_URL = r'https?://play\.iprima\.cz/[^?#]+/(?P<id>[^?#]+)'
16 'url': 'http://play.iprima.cz/particka/particka-92',
20 'title': 'Partička (92)',
21 'description': 'md5:3740fda51464da35a2d4d0670b8e4fd6',
22 'thumbnail': 'http://play.iprima.cz/sites/default/files/image_crops/image_620x349/3/491483_particka-92_image_620x349.jpg',
25 'skip_download': True,
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
34 webpage = self._download_webpage(url, video_id)
36 player_url = 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' % (
37 floor(random()*1073741824),
38 floor(random()*1073741824))
40 req = compat_urllib_request.Request(player_url)
41 req.add_header('Referer', url)
42 playerpage = self._download_webpage(req, video_id)
44 base_url = ''.join(re.findall(r"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage)[1])
46 zoneGEO = self._html_search_regex(r'"zoneGEO":(.+?),', webpage, 'zoneGEO')
48 base_url = base_url.replace('token', 'token_' + zoneGEO)
51 for format_id in ['lq', 'hq', 'hd']:
52 filename = self._html_search_regex(
53 r'"%s_id":(.+?),' % format_id, webpage, 'filename')
55 if filename == 'null':
58 real_id = self._search_regex(
59 r'Prima-[0-9]{10}-([0-9]+)_', filename, 'real video id')
63 elif format_id == 'hq':
65 elif format_id == 'hd':
67 filename = 'hq/' + filename
70 'format_id': format_id,
73 'play_path': 'mp4:' + filename.replace('"', '')[:-4],
78 self._sort_formats(formats)
82 'title': self._og_search_title(webpage),
83 'thumbnail': self._og_search_thumbnail(webpage),
85 'description': self._og_search_description(webpage),