]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | determine_ext, | |
4 | int_or_none, | |
5 | url_or_none, | |
6 | ) | |
7 | ||
8 | ||
9 | class RENTVIE(InfoExtractor): | |
10 | _WORKING = False | |
11 | _VALID_URL = r'(?:rentv:|https?://(?:www\.)?ren\.tv/(?:player|video/epizod)/)(?P<id>\d+)' | |
12 | _TESTS = [{ | |
13 | 'url': 'http://ren.tv/video/epizod/118577', | |
14 | 'md5': 'd91851bf9af73c0ad9b2cdf76c127fbb', | |
15 | 'info_dict': { | |
16 | 'id': '118577', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Документальный спецпроект: "Промывка мозгов. Технологии XXI века"', | |
19 | 'timestamp': 1472230800, | |
20 | 'upload_date': '20160826', | |
21 | }, | |
22 | }, { | |
23 | 'url': 'http://ren.tv/player/118577', | |
24 | 'only_matching': True, | |
25 | }, { | |
26 | 'url': 'rentv:118577', | |
27 | 'only_matching': True, | |
28 | }] | |
29 | ||
30 | def _real_extract(self, url): | |
31 | video_id = self._match_id(url) | |
32 | webpage = self._download_webpage('http://ren.tv/player/' + video_id, video_id) | |
33 | config = self._parse_json(self._search_regex( | |
34 | r'config\s*=\s*({.+})\s*;', webpage, 'config'), video_id) | |
35 | title = config['title'] | |
36 | formats = [] | |
37 | for video in config['src']: | |
38 | src = url_or_none(video.get('src')) | |
39 | if not src: | |
40 | continue | |
41 | ext = determine_ext(src) | |
42 | if ext == 'm3u8': | |
43 | formats.extend(self._extract_m3u8_formats( | |
44 | src, video_id, 'mp4', entry_protocol='m3u8_native', | |
45 | m3u8_id='hls', fatal=False)) | |
46 | else: | |
47 | formats.append({ | |
48 | 'url': src, | |
49 | }) | |
50 | return { | |
51 | 'id': video_id, | |
52 | 'title': title, | |
53 | 'description': config.get('description'), | |
54 | 'thumbnail': config.get('image'), | |
55 | 'duration': int_or_none(config.get('duration')), | |
56 | 'timestamp': int_or_none(config.get('date')), | |
57 | 'formats': formats, | |
58 | } | |
59 | ||
60 | ||
61 | class RENTVArticleIE(InfoExtractor): | |
62 | _WORKING = False | |
63 | _VALID_URL = r'https?://(?:www\.)?ren\.tv/novosti/\d{4}-\d{2}-\d{2}/(?P<id>[^/?#]+)' | |
64 | _TESTS = [{ | |
65 | 'url': 'http://ren.tv/novosti/2016-10-26/video-mikroavtobus-popavshiy-v-dtp-s-gruzovikami-v-podmoskove-prevratilsya-v', | |
66 | 'md5': 'ebd63c4680b167693745ab91343df1d6', | |
67 | 'info_dict': { | |
68 | 'id': '136472', | |
69 | 'ext': 'mp4', | |
70 | 'title': 'Видео: микроавтобус, попавший в ДТП с грузовиками в Подмосковье, превратился в груду металла', | |
71 | 'description': 'Жертвами столкновения двух фур и микроавтобуса, по последним данным, стали семь человек.', | |
72 | }, | |
73 | }, { | |
74 | # TODO: invalid m3u8 | |
75 | 'url': 'http://ren.tv/novosti/2015-09-25/sluchaynyy-prohozhiy-poymal-avtougonshchika-v-murmanske-video', | |
76 | 'info_dict': { | |
77 | 'id': 'playlist', | |
78 | 'ext': 'mp4', | |
79 | 'title': 'Случайный прохожий поймал автоугонщика в Мурманске. ВИДЕО | РЕН ТВ', | |
80 | 'uploader': 'ren.tv', | |
81 | }, | |
82 | 'params': { | |
83 | # m3u8 downloads | |
84 | 'skip_download': True, | |
85 | }, | |
86 | 'skip': True, | |
87 | }] | |
88 | ||
89 | def _real_extract(self, url): | |
90 | display_id = self._match_id(url) | |
91 | webpage = self._download_webpage(url, display_id) | |
92 | drupal_settings = self._parse_json(self._search_regex( | |
93 | r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', | |
94 | webpage, 'drupal settings'), display_id) | |
95 | ||
96 | entries = [] | |
97 | for config_profile in drupal_settings.get('ren_jwplayer', {}).values(): | |
98 | media_id = config_profile.get('mediaid') | |
99 | if not media_id: | |
100 | continue | |
101 | media_id = str(media_id) | |
102 | entries.append(self.url_result('rentv:' + media_id, 'RENTV', media_id)) | |
103 | return self.playlist_result(entries, display_id) |