2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_str
12 class RENTVIE(InfoExtractor):
13 _VALID_URL = r'(?:rentv:|https?://(?:www\.)?ren\.tv/(?:player|video/epizod)/)(?P<id>\d+)'
15 'url': 'http://ren.tv/video/epizod/118577',
16 'md5': 'd91851bf9af73c0ad9b2cdf76c127fbb',
20 'title': 'Документальный спецпроект: "Промывка мозгов. Технологии XXI века"',
21 'timestamp': 1472230800,
22 'upload_date': '20160826',
25 'url': 'http://ren.tv/player/118577',
26 'only_matching': True,
28 'url': 'rentv:118577',
29 'only_matching': True,
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
34 webpage = self._download_webpage('http://ren.tv/player/' + video_id, video_id)
35 config = self._parse_json(self._search_regex(
36 r'config\s*=\s*({.+})\s*;', webpage, 'config'), video_id)
37 title = config['title']
39 for video in config['src']:
40 src = video.get('src')
41 if not src or not isinstance(src, compat_str):
43 ext = determine_ext(src)
45 formats.extend(self._extract_m3u8_formats(
46 src, video_id, 'mp4', entry_protocol='m3u8_native',
47 m3u8_id='hls', fatal=False))
52 self._sort_formats(formats)
56 'description': config.get('description'),
57 'thumbnail': config.get('image'),
58 'duration': int_or_none(config.get('duration')),
59 'timestamp': int_or_none(config.get('date')),
64 class RENTVArticleIE(InfoExtractor):
65 _VALID_URL = r'https?://(?:www\.)?ren\.tv/novosti/\d{4}-\d{2}-\d{2}/(?P<id>[^/?#]+)'
67 'url': 'http://ren.tv/novosti/2016-10-26/video-mikroavtobus-popavshiy-v-dtp-s-gruzovikami-v-podmoskove-prevratilsya-v',
68 'md5': 'ebd63c4680b167693745ab91343df1d6',
72 'title': 'Видео: микроавтобус, попавший в ДТП с грузовиками в Подмосковье, превратился в груду металла',
73 'description': 'Жертвами столкновения двух фур и микроавтобуса, по последним данным, стали семь человек.',
77 'url': 'http://ren.tv/novosti/2015-09-25/sluchaynyy-prohozhiy-poymal-avtougonshchika-v-murmanske-video',
81 'title': 'Случайный прохожий поймал автоугонщика в Мурманске. ВИДЕО | РЕН ТВ',
86 'skip_download': True,
91 def _real_extract(self, url):
92 display_id = self._match_id(url)
93 webpage = self._download_webpage(url, display_id)
94 drupal_settings = self._parse_json(self._search_regex(
95 r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
96 webpage, 'drupal settings'), display_id)
99 for config_profile in drupal_settings.get('ren_jwplayer', {}).values():
100 media_id = config_profile.get('mediaid')
103 media_id = compat_str(media_id)
104 entries.append(self.url_result('rentv:' + media_id, 'RENTV', media_id))
105 return self.playlist_result(entries, display_id)