]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/iprima.py
   1 # -*- coding: utf-8 -*- 
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
  13 class IPrimaIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://play\.iprima\.cz/(?:.+/)?(?P<id>[^?#]+)' 
  17         'url': 'http://play.iprima.cz/gondici-s-r-o-33', 
  21             'title': 'Gondíci s. r. o. (34)', 
  22             'description': 'md5:16577c629d006aa91f59ca8d8e7f99bd', 
  25             'skip_download': True,  # m3u8 download 
  28         'url': 'http://play.iprima.cz/particka/particka-92', 
  29         'only_matching': True, 
  32     def _real_extract(self
, url
): 
  33         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  34         video_id 
= mobj
.group('id') 
  36         webpage 
= self
._download
_webpage
(url
, video_id
) 
  38         video_id 
= self
._search
_regex
(r
'data-product="([^"]+)">', webpage
, 'real id') 
  40         req 
= sanitized_Request( 
  41             'http://play.iprima.cz/prehravac/init?_infuse=1' 
  42             '&_ts=%s&productId=%s' % (round(time
.time()), video_id
)) 
  43         req
.add_header('Referer', url
) 
  44         playerpage 
= self
._download
_webpage
(req
, video_id
, note
='Downloading player') 
  46         m3u8_url 
= self
._search
_regex
(r
"'src': '([^']+\.m3u8)'", playerpage
, 'm3u8 url') 
  48         formats 
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, ext
='mp4') 
  50         self
._sort
_formats
(formats
) 
  54             'title': self
._og
_search
_title
(webpage
), 
  55             'thumbnail': self
._og
_search
_thumbnail
(webpage
), 
  57             'description': self
._og
_search
_description
(webpage
),