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