]>
Commit | Line | Data |
---|---|---|
0f6ed94a S |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
0f6ed94a S |
4 | from .common import InfoExtractor |
5 | from ..utils import int_or_none | |
6 | ||
7 | ||
8 | class FirstTVIE(InfoExtractor): | |
9347fddb S |
9 | IE_NAME = '1tv' |
10 | IE_DESC = 'Первый канал' | |
11 | _VALID_URL = r'http://(?:www\.)?1tv\.ru/(?:[^/]+/)+(?P<id>.+)' | |
0f6ed94a | 12 | |
9347fddb | 13 | _TESTS = [{ |
0f6ed94a | 14 | 'url': 'http://www.1tv.ru/videoarchive/73390', |
9347fddb | 15 | 'md5': '777f525feeec4806130f4f764bc18a4f', |
0f6ed94a S |
16 | 'info_dict': { |
17 | 'id': '73390', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Олимпийские канатные дороги', | |
9347fddb S |
20 | 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', |
21 | 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$', | |
0f6ed94a | 22 | 'duration': 149, |
9347fddb S |
23 | 'like_count': int, |
24 | 'dislike_count': int, | |
cb389289 S |
25 | }, |
26 | 'skip': 'Only works from Russia', | |
9347fddb S |
27 | }, { |
28 | 'url': 'http://www.1tv.ru/prj/inprivate/vypusk/35930', | |
29 | 'md5': 'a1b6b60d530ebcf8daacf4565762bbaf', | |
30 | 'info_dict': { | |
31 | 'id': '35930', | |
32 | 'ext': 'mp4', | |
33 | 'title': 'Наедине со всеми. Людмила Сенчина', | |
34 | 'description': 'md5:89553aed1d641416001fe8d450f06cb9', | |
35 | 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$', | |
36 | 'duration': 2694, | |
37 | }, | |
38 | 'skip': 'Only works from Russia', | |
39 | }] | |
0f6ed94a S |
40 | |
41 | def _real_extract(self, url): | |
9347fddb | 42 | video_id = self._match_id(url) |
0f6ed94a S |
43 | |
44 | webpage = self._download_webpage(url, video_id, 'Downloading page') | |
45 | ||
46 | video_url = self._html_search_regex( | |
9347fddb S |
47 | r'''(?s)(?:jwplayer\('flashvideoportal_1'\)\.setup\({|var\s+playlistObj\s*=).*?'file'\s*:\s*'([^']+)'.*?}\);''', |
48 | webpage, 'video URL') | |
0f6ed94a S |
49 | |
50 | title = self._html_search_regex( | |
9347fddb S |
51 | [r'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>', |
52 | r"'title'\s*:\s*'([^']+)'"], webpage, 'title') | |
0f6ed94a | 53 | description = self._html_search_regex( |
9347fddb S |
54 | r'<div class="descr">\s*<div> </div>\s*<p>([^<]*)</p></div>', |
55 | webpage, 'description', default=None) or self._html_search_meta( | |
56 | 'description', webpage, 'description') | |
0f6ed94a S |
57 | |
58 | thumbnail = self._og_search_thumbnail(webpage) | |
9347fddb S |
59 | duration = self._og_search_property( |
60 | 'video:duration', webpage, | |
61 | 'video duration', fatal=False) | |
0f6ed94a | 62 | |
9347fddb S |
63 | like_count = self._html_search_regex( |
64 | r'title="Понравилось".*?/></label> \[(\d+)\]', | |
65 | webpage, 'like count', default=None) | |
66 | dislike_count = self._html_search_regex( | |
67 | r'title="Не понравилось".*?/></label> \[(\d+)\]', | |
68 | webpage, 'dislike count', default=None) | |
0f6ed94a S |
69 | |
70 | return { | |
71 | 'id': video_id, | |
72 | 'url': video_url, | |
73 | 'thumbnail': thumbnail, | |
74 | 'title': title, | |
75 | 'description': description, | |
76 | 'duration': int_or_none(duration), | |
77 | 'like_count': int_or_none(like_count), | |
78 | 'dislike_count': int_or_none(dislike_count), | |
5f6a1245 | 79 | } |