]>
Commit | Line | Data |
---|---|---|
8944ec01 S |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import json | |
5 | import re | |
6 | ||
7 | from .common import InfoExtractor | |
8 | from ..utils import ( | |
9 | int_or_none, | |
10 | unescapeHTML, | |
11 | ) | |
12 | ||
13 | ||
14 | class KrasViewIE(InfoExtractor): | |
15 | IE_DESC = 'Красвью' | |
16 | _VALID_URL = r'https?://krasview\.ru/video/(?P<id>\d+)' | |
17 | ||
18 | _TEST = { | |
19 | 'url': 'http://krasview.ru/video/512228', | |
20 | 'md5': '3b91003cf85fc5db277870c8ebd98eae', | |
21 | 'info_dict': { | |
22 | 'id': '512228', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Снег, лёд, заносы', | |
25 | 'description': 'Снято в городе Нягань, в Ханты-Мансийском автономном округе.', | |
26 | 'duration': 27, | |
27 | 'thumbnail': 're:^https?://.*\.jpg', | |
28 | }, | |
29 | } | |
30 | ||
31 | def _real_extract(self, url): | |
32 | mobj = re.match(self._VALID_URL, url) | |
33 | video_id = mobj.group('id') | |
34 | ||
35 | webpage = self._download_webpage(url, video_id) | |
36 | ||
37 | flashvars = json.loads(self._search_regex( | |
38 | r'flashvars\s*:\s*({.+?})\s*}\);', webpage, 'flashvars')) | |
39 | ||
40 | video_url = flashvars['url'] | |
41 | title = unescapeHTML(flashvars['title']) | |
42 | description = unescapeHTML(flashvars.get('subtitle') or self._og_search_description(webpage, default=None)) | |
43 | thumbnail = flashvars['image'] | |
44 | duration = int(flashvars['duration']) | |
45 | filesize = int(flashvars['size']) | |
46 | width = int_or_none(self._og_search_property('video:width', webpage, 'video width')) | |
47 | height = int_or_none(self._og_search_property('video:height', webpage, 'video height')) | |
48 | ||
49 | return { | |
50 | 'id': video_id, | |
51 | 'url': video_url, | |
52 | 'title': title, | |
53 | 'description': description, | |
54 | 'thumbnail': thumbnail, | |
55 | 'duration': duration, | |
56 | 'filesize': filesize, | |
57 | 'width': width, | |
58 | 'height': height, | |
59 | } |