]>
jfr.im git - yt-dlp.git/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
,
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
42 'skip': 'Do not have permission to access this page',
45 def _real_extract(self
, url
):
46 mobj
= re
.match(self
._VALID
_URL
, url
)
47 video_id
= mobj
.group('id')
49 webpage
= self
._download
_webpage
(url
, video_id
)
51 if re
.search(r
'Nemáte oprávnění přistupovat na tuto stránku\.\s*</div>', webpage
):
53 '%s said: You do not have permission to access this page' % self
.IE_NAME
, expected
=True)
56 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
57 (floor(random()*1073741824), floor(random()*1073741824))
60 req
= compat_urllib_request
.Request(player_url
)
61 req
.add_header('Referer', url
)
62 playerpage
= self
._download
_webpage
(req
, video_id
)
64 base_url
= ''.join(re
.findall(r
"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage
)[1])
66 zoneGEO
= self
._html
_search
_regex
(r
'"zoneGEO":(.+?),', webpage
, 'zoneGEO')
68 base_url
= base_url
.replace('token', 'token_' + zoneGEO
)
71 for format_id
in ['lq', 'hq', 'hd']:
72 filename
= self
._html
_search
_regex
(
73 r
'"%s_id":(.+?),' % format_id
, webpage
, 'filename')
75 if filename
== 'null':
78 real_id
= self
._search
_regex
(
79 r
'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
80 filename
, 'real video id')
84 elif format_id
== 'hq':
86 elif format_id
== 'hd':
88 filename
= 'hq/' + filename
91 'format_id': format_id
,
94 'play_path': 'mp4:' + filename
.replace('"', '')[:-4],
99 self
._sort
_formats
(formats
)
103 'title': self
._og
_search
_title
(webpage
),
104 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
106 'description': self
._og
_search
_description
(webpage
),