2014-02-04 00:45:41 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
2016-02-06 14:23:41 -06:00
|
|
|
import time
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2014-12-13 05:24:42 -06:00
|
|
|
from ..utils import (
|
2015-11-21 10:18:17 -06:00
|
|
|
sanitized_Request,
|
2014-03-14 13:38:44 -05:00
|
|
|
)
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
class IPrimaIE(InfoExtractor):
|
2016-02-06 14:23:41 -06:00
|
|
|
_VALID_URL = r'https?://play\.iprima\.cz/(?:.+/)?(?P<id>[^?#]+)'
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
_TESTS = [{
|
2016-02-06 14:23:41 -06:00
|
|
|
'url': 'http://play.iprima.cz/gondici-s-r-o-33',
|
2014-02-04 00:45:41 -06:00
|
|
|
'info_dict': {
|
2016-02-06 14:23:41 -06:00
|
|
|
'id': 'p136534',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Gondíci s. r. o. (34)',
|
|
|
|
'description': 'md5:16577c629d006aa91f59ca8d8e7f99bd',
|
2014-02-04 00:45:41 -06:00
|
|
|
},
|
|
|
|
'params': {
|
2016-02-06 14:23:41 -06:00
|
|
|
'skip_download': True, # m3u8 download
|
2014-02-04 00:45:41 -06:00
|
|
|
},
|
2014-02-24 03:12:36 -06:00
|
|
|
}, {
|
2016-02-06 14:23:41 -06:00
|
|
|
'url': 'http://play.iprima.cz/particka/particka-92',
|
2015-06-02 05:16:58 -05:00
|
|
|
'only_matching': True,
|
2014-02-24 03:12:36 -06:00
|
|
|
}]
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
2014-02-24 02:53:48 -06:00
|
|
|
video_id = mobj.group('id')
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2016-02-06 14:23:41 -06:00
|
|
|
video_id = self._search_regex(r'data-product="([^"]+)">', webpage, 'real id')
|
2014-03-14 13:38:44 -05:00
|
|
|
|
2016-02-06 14:37:28 -06:00
|
|
|
req = sanitized_Request(
|
|
|
|
'http://play.iprima.cz/prehravac/init?_infuse=1'
|
2016-02-06 14:42:24 -06:00
|
|
|
'&_ts=%s&productId=%s' % (round(time.time()), video_id))
|
2014-02-04 00:45:41 -06:00
|
|
|
req.add_header('Referer', url)
|
2016-02-06 14:23:41 -06:00
|
|
|
playerpage = self._download_webpage(req, video_id, note='Downloading player')
|
2014-02-04 00:45:41 -06:00
|
|
|
|
2016-02-06 14:23:41 -06:00
|
|
|
m3u8_url = self._search_regex(r"'src': '([^']+\.m3u8)'", playerpage, 'm3u8 url')
|
2014-02-04 00:45:41 -06:00
|
|
|
|
2016-02-06 14:23:41 -06:00
|
|
|
formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')
|
2014-02-04 03:24:00 -06:00
|
|
|
|
|
|
|
self._sort_formats(formats)
|
2014-02-04 00:45:41 -06:00
|
|
|
|
|
|
|
return {
|
2016-02-06 14:23:41 -06:00
|
|
|
'id': video_id,
|
|
|
|
'title': self._og_search_title(webpage),
|
2014-02-04 00:45:41 -06:00
|
|
|
'thumbnail': self._og_search_thumbnail(webpage),
|
|
|
|
'formats': formats,
|
2016-02-06 14:23:41 -06:00
|
|
|
'description': self._og_search_description(webpage),
|
2014-02-04 03:24:00 -06:00
|
|
|
}
|