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