2016-10-26 10:07:35 +01:00
|
|
|
|
# coding: utf-8
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..compat import compat_str
|
2018-04-21 23:22:10 +07:00
|
|
|
|
from ..utils import (
|
|
|
|
|
determine_ext,
|
|
|
|
|
int_or_none,
|
2018-07-21 19:08:28 +07:00
|
|
|
|
url_or_none,
|
2018-04-21 23:22:10 +07:00
|
|
|
|
)
|
2016-10-26 10:07:35 +01:00
|
|
|
|
|
|
|
|
|
|
2017-02-16 23:42:36 +08:00
|
|
|
|
class RENTVIE(InfoExtractor):
|
2016-10-26 10:07:35 +01:00
|
|
|
|
_VALID_URL = r'(?:rentv:|https?://(?:www\.)?ren\.tv/(?:player|video/epizod)/)(?P<id>\d+)'
|
2016-10-26 19:52:43 +07:00
|
|
|
|
_TESTS = [{
|
2016-10-26 10:07:35 +01:00
|
|
|
|
'url': 'http://ren.tv/video/epizod/118577',
|
|
|
|
|
'md5': 'd91851bf9af73c0ad9b2cdf76c127fbb',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '118577',
|
|
|
|
|
'ext': 'mp4',
|
2018-04-21 23:22:10 +07:00
|
|
|
|
'title': 'Документальный спецпроект: "Промывка мозгов. Технологии XXI века"',
|
|
|
|
|
'timestamp': 1472230800,
|
|
|
|
|
'upload_date': '20160826',
|
2016-10-26 10:07:35 +01:00
|
|
|
|
}
|
2016-10-26 19:52:43 +07:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'http://ren.tv/player/118577',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'rentv:118577',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}]
|
2016-10-26 10:07:35 +01:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage('http://ren.tv/player/' + video_id, video_id)
|
2018-01-12 07:01:02 +13:00
|
|
|
|
config = self._parse_json(self._search_regex(
|
2018-04-21 23:22:10 +07:00
|
|
|
|
r'config\s*=\s*({.+})\s*;', webpage, 'config'), video_id)
|
|
|
|
|
title = config['title']
|
2018-01-12 07:01:02 +13:00
|
|
|
|
formats = []
|
2018-04-21 23:22:10 +07:00
|
|
|
|
for video in config['src']:
|
2018-07-21 19:08:28 +07:00
|
|
|
|
src = url_or_none(video.get('src'))
|
|
|
|
|
if not src:
|
2018-04-21 23:22:10 +07:00
|
|
|
|
continue
|
|
|
|
|
ext = determine_ext(src)
|
|
|
|
|
if ext == 'm3u8':
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
|
src, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
|
|
|
m3u8_id='hls', fatal=False))
|
|
|
|
|
else:
|
|
|
|
|
formats.append({
|
|
|
|
|
'url': src,
|
|
|
|
|
})
|
2018-01-12 07:01:02 +13:00
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
2018-04-21 23:22:10 +07:00
|
|
|
|
'title': title,
|
|
|
|
|
'description': config.get('description'),
|
|
|
|
|
'thumbnail': config.get('image'),
|
|
|
|
|
'duration': int_or_none(config.get('duration')),
|
|
|
|
|
'timestamp': int_or_none(config.get('date')),
|
2018-01-12 07:01:02 +13:00
|
|
|
|
'formats': formats,
|
|
|
|
|
}
|
2016-10-26 10:07:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RENTVArticleIE(InfoExtractor):
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?ren\.tv/novosti/\d{4}-\d{2}-\d{2}/(?P<id>[^/?#]+)'
|
2016-10-26 19:52:43 +07:00
|
|
|
|
_TESTS = [{
|
|