]>
Commit | Line | Data |
---|---|---|
99ac0390 | 1 | from .common import InfoExtractor |
499a0777 | 2 | from ..utils import int_or_none |
99ac0390 HL |
3 | |
4 | ||
5 | class FiveTVIE(InfoExtractor): | |
499a0777 | 6 | _VALID_URL = r'''(?x) |
0dd58a52 | 7 | https?:// |
499a0777 S |
8 | (?:www\.)?5-tv\.ru/ |
9 | (?: | |
10 | (?:[^/]+/)+(?P<id>\d+)| | |
11 | (?P<path>[^/?#]+)(?:[/?#])? | |
12 | ) | |
13 | ''' | |
14 | ||
15 | _TESTS = [{ | |
16 | 'url': 'http://5-tv.ru/news/96814/', | |
17 | 'md5': 'bbff554ad415ecf5416a2f48c22d9283', | |
18 | 'info_dict': { | |
19 | 'id': '96814', | |
20 | 'ext': 'mp4', | |
21 | 'title': 'Россияне выбрали имя для общенациональной платежной системы', | |
22 | 'description': 'md5:a8aa13e2b7ad36789e9f77a74b6de660', | |
ec85ded8 | 23 | 'thumbnail': r're:^https?://.*\.jpg$', |
499a0777 | 24 | 'duration': 180, |
99ac0390 | 25 | }, |
499a0777 S |
26 | }, { |
27 | 'url': 'http://5-tv.ru/video/1021729/', | |
28 | 'info_dict': { | |
29 | 'id': '1021729', | |
30 | 'ext': 'mp4', | |
31 | 'title': '3D принтер', | |
32 | 'description': 'md5:d76c736d29ef7ec5c0cf7d7c65ffcb41', | |
ec85ded8 | 33 | 'thumbnail': r're:^https?://.*\.jpg$', |
499a0777 | 34 | 'duration': 180, |
99ac0390 | 35 | }, |
499a0777 | 36 | }, { |
0dd58a52 | 37 | # redirect to https://www.5-tv.ru/projects/1000095/izvestia-glavnoe/ |
499a0777 S |
38 | 'url': 'http://www.5-tv.ru/glavnoe/#itemDetails', |
39 | 'info_dict': { | |
40 | 'id': 'glavnoe', | |
41 | 'ext': 'mp4', | |
f354d848 | 42 | 'title': r're:^Итоги недели с \d+ по \d+ \w+ \d{4} года$', |
ec85ded8 | 43 | 'thumbnail': r're:^https?://.*\.jpg$', |
499a0777 | 44 | }, |
0dd58a52 | 45 | 'skip': 'redirect to «Известия. Главное» project page', |
499a0777 S |
46 | }, { |
47 | 'url': 'http://www.5-tv.ru/glavnoe/broadcasts/508645/', | |
48 | 'only_matching': True, | |
49 | }, { | |
50 | 'url': 'http://5-tv.ru/films/1507502/', | |
51 | 'only_matching': True, | |
52 | }, { | |
53 | 'url': 'http://5-tv.ru/programs/broadcast/508713/', | |
54 | 'only_matching': True, | |
55 | }, { | |
56 | 'url': 'http://5-tv.ru/angel/', | |
57 | 'only_matching': True, | |
58 | }, { | |
59 | 'url': 'http://www.5-tv.ru/schedule/?iframe=true&width=900&height=450', | |
60 | 'only_matching': True, | |
61 | }] | |
99ac0390 HL |
62 | |
63 | def _real_extract(self, url): | |
5ad28e7f | 64 | mobj = self._match_valid_url(url) |
499a0777 | 65 | video_id = mobj.group('id') or mobj.group('path') |
99ac0390 HL |
66 | |
67 | webpage = self._download_webpage(url, video_id) | |
68 | ||
499a0777 | 69 | video_url = self._search_regex( |
0dd58a52 | 70 | [r'<div[^>]+?class="(?:flow)?player[^>]+?data-href="([^"]+)"', |
f354d848 | 71 | r'<a[^>]+?href="([^"]+)"[^>]+?class="videoplayer"'], |
499a0777 | 72 | webpage, 'video url') |
99ac0390 | 73 | |
62b8dac4 | 74 | title = self._generic_title('', webpage) |
99ac0390 | 75 | duration = int_or_none(self._og_search_property( |
499a0777 S |
76 | 'video:duration', webpage, 'duration', default=None)) |
77 | ||
99ac0390 HL |
78 | return { |
79 | 'id': video_id, | |
499a0777 S |
80 | 'url': video_url, |
81 | 'title': title, | |
82 | 'description': self._og_search_description(webpage, default=None), | |
83 | 'thumbnail': self._og_search_thumbnail(webpage, default=None), | |
99ac0390 HL |
84 | 'duration': duration, |
85 | } |