]>
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
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:74e9617e51bca67c3ecfb2c6f9766f45',
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 'thumbnail': 're:^http:.*\.jpg$',
42 'skip_download': True, # requires rtmpdump
45 'url': 'http://play.iprima.cz/zpravy-ftv-prima-2752015',
46 'only_matching': True,
49 def _real_extract(self
, url
):
50 mobj
= re
.match(self
._VALID
_URL
, url
)
51 video_id
= mobj
.group('id')
53 webpage
= self
._download
_webpage
(url
, video_id
)
55 if re
.search(r
'Nemáte oprávnění přistupovat na tuto stránku\.\s*</div>', webpage
):
57 '%s said: You do not have permission to access this page' % self
.IE_NAME
, expected
=True)
60 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
61 (floor(random() * 1073741824), floor(random() * 1073741824))
64 req
= compat_urllib_request
.Request(player_url
)
65 req
.add_header('Referer', url
)
66 playerpage
= self
._download
_webpage
(req
, video_id
)
68 base_url
= ''.join(re
.findall(r
"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage
)[1])
70 zoneGEO
= self
._html
_search
_regex
(r
'"zoneGEO":(.+?),', webpage
, 'zoneGEO')
72 base_url
= base_url
.replace('token', 'token_' + zoneGEO
)
75 for format_id
in ['lq', 'hq', 'hd']:
76 filename
= self
._html
_search
_regex
(
77 r
'"%s_id":(.+?),' % format_id
, webpage
, 'filename')
79 if filename
== 'null':
82 real_id
= self
._search
_regex
(
83 r
'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
84 filename
, 'real video id')
88 elif format_id
== 'hq':
90 elif format_id
== 'hd':
92 filename
= 'hq/' + filename
95 'format_id': format_id
,
98 'play_path': 'mp4:' + filename
.replace('"', '')[:-4],
103 self
._sort
_formats
(formats
)
107 'title': remove_end(self
._og
_search
_title
(webpage
), ' | Prima PLAY'),
108 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
110 'description': self
._search
_regex
(
111 r
'<p[^>]+itemprop="description"[^>]*>([^<]+)',
112 webpage
, 'description', default
=None),