]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/iprima.py
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
5 from random
import random
8 from .common
import InfoExtractor
16 class IPrimaIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://play\.iprima\.cz/(?:[^/]+/)*(?P<id>[^?#]+)'
20 'url': 'http://play.iprima.cz/particka/particka-92',
24 'title': 'Partička (92)',
25 'description': 'md5:74e9617e51bca67c3ecfb2c6f9766f45',
26 'thumbnail': 'http://play.iprima.cz/sites/default/files/image_crops/image_620x349/3/491483_particka-92_image_620x349.jpg',
29 'skip_download': True, # requires rtmpdump
32 'url': 'http://play.iprima.cz/particka/tchibo-particka-jarni-moda',
36 'title': 'Tchibo Partička - Jarní móda',
37 'thumbnail': 're:^http:.*\.jpg$',
40 'skip_download': True, # requires rtmpdump
43 'url': 'http://play.iprima.cz/zpravy-ftv-prima-2752015',
44 'only_matching': True,
47 def _real_extract(self
, url
):
48 mobj
= re
.match(self
._VALID
_URL
, url
)
49 video_id
= mobj
.group('id')
51 webpage
= self
._download
_webpage
(url
, video_id
)
53 if re
.search(r
'Nemáte oprávnění přistupovat na tuto stránku\.\s*</div>', webpage
):
55 '%s said: You do not have permission to access this page' % self
.IE_NAME
, expected
=True)
58 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
59 (floor(random() * 1073741824), floor(random() * 1073741824))
62 req
= sanitized_Request(player_url
)
63 req
.add_header('Referer', url
)
64 playerpage
= self
._download
_webpage
(req
, video_id
)
66 base_url
= ''.join(re
.findall(r
"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage
)[1])
68 zoneGEO
= self
._html
_search
_regex
(r
'"zoneGEO":(.+?),', webpage
, 'zoneGEO')
70 base_url
= base_url
.replace('token', 'token_' + zoneGEO
)
73 for format_id
in ['lq', 'hq', 'hd']:
74 filename
= self
._html
_search
_regex
(
75 r
'"%s_id":(.+?),' % format_id
, webpage
, 'filename')
77 if filename
== 'null':
80 real_id
= self
._search
_regex
(
81 r
'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
82 filename
, 'real video id')
86 elif format_id
== 'hq':
88 elif format_id
== 'hd':
90 filename
= 'hq/' + filename
93 'format_id': format_id
,
96 'play_path': 'mp4:' + filename
.replace('"', '')[:-4],
101 self
._sort
_formats
(formats
)
105 'title': remove_end(self
._og
_search
_title
(webpage
), ' | Prima PLAY'),
106 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
108 'description': self
._search
_regex
(
109 r
'<p[^>]+itemprop="description"[^>]*>([^<]+)',
110 webpage
, 'description', default
=None),