1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2026-05-23 13:55:29 +00:00
Files
youtube-dl/youtube_dl/extractor/iprima.py
T

59 lines
1.7 KiB
Python
Raw Normal View History

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