]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/iprima.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
15 class IPrimaIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://play\.iprima\.cz/(?:.+/)?(?P<id>[^?#]+)'
19 'url': 'http://play.iprima.cz/gondici-s-r-o-33',
23 'title': 'Gondíci s. r. o. (34)',
24 'description': 'md5:16577c629d006aa91f59ca8d8e7f99bd',
27 'skip_download': True, # m3u8 download
30 'url': 'http://play.iprima.cz/particka/particka-92',
31 'only_matching': True,
34 def _real_extract(self
, url
):
35 video_id
= self
._match
_id
(url
)
37 webpage
= self
._download
_webpage
(url
, video_id
)
39 video_id
= self
._search
_regex
(r
'data-product="([^"]+)">', webpage
, 'real id')
41 req
= sanitized_Request(
42 'http://play.iprima.cz/prehravac/init?_infuse=1'
43 '&_ts=%s&productId=%s' % (round(time
.time()), video_id
))
44 req
.add_header('Referer', url
)
45 playerpage
= self
._download
_webpage
(req
, video_id
, note
='Downloading player')
49 def extract_formats(format_url
, format_key
=None, lang
=None):
50 ext
= determine_ext(format_url
)
52 if format_key
== 'hls' or ext
== 'm3u8':
53 new_formats
= self
._extract
_m
3u8_formats
(
54 format_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
55 m3u8_id
='hls', fatal
=False)
56 elif format_key
== 'dash' or ext
== 'mpd':
58 new_formats
= self
._extract
_mpd
_formats
(
59 format_url
, video_id
, mpd_id
='dash', fatal
=False)
62 if not f
.get('language'):
64 formats
.extend(new_formats
)
66 options
= self
._parse
_json
(
68 r
'(?s)var\s+playerOptions\s*=\s*({.+?});',
69 playerpage
, 'player options', default
='{}'),
70 video_id
, transform_source
=js_to_json
, fatal
=False)
72 for key
, tracks
in options
.get('tracks', {}).items():
73 if not isinstance(tracks
, list):
76 src
= track
.get('src')
78 extract_formats(src
, key
.lower(), track
.get('lang'))
81 for _
, src
in re
.findall(r
'src["\']\s
*:\s
*(["\'])(.+?)\1', playerpage):
84 self._sort_formats(formats)
88 'title': self._og_search_title(webpage),
89 'thumbnail': self._og_search_thumbnail(webpage),
91 'description': self._og_search_description(webpage),