]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/krasview.py
[xuite] Update tests
[yt-dlp.git] / youtube_dl / extractor / krasview.py
CommitLineData
8944ec01
S
1# encoding: utf-8
2from __future__ import unicode_literals
3
4import json
8944ec01
S
5
6from .common import InfoExtractor
7from ..utils import (
8 int_or_none,
1e108029 9 js_to_json,
8944ec01
S
10)
11
12
13class 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 },
28 }
29
30 def _real_extract(self, url):
1e108029 31 video_id = self._match_id(url)
8944ec01
S
32
33 webpage = self._download_webpage(url, video_id)
34
1e108029
S
35 flashvars = json.loads(js_to_json(self._search_regex(
36 r'video_Init\(({.+?})', webpage, 'flashvars')))
8944ec01
S
37
38 video_url = flashvars['url']
1e108029
S
39 title = self._og_search_title(webpage)
40 description = self._og_search_description(webpage, default=None)
41 thumbnail = flashvars.get('image') or self._og_search_thumbnail(webpage)
42 duration = int_or_none(flashvars.get('duration'))
8944ec01
S
43 width = int_or_none(self._og_search_property('video:width', webpage, 'video width'))
44 height = int_or_none(self._og_search_property('video:height', webpage, 'video height'))
45
46 return {
47 'id': video_id,
48 'url': video_url,
49 'title': title,
50 'description': description,
51 'thumbnail': thumbnail,
52 'duration': duration,
8944ec01
S
53 'width': width,
54 'height': height,
55 }