]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/krasview.py
[ie] Migrate commonly plural fields to lists (#8917)
[yt-dlp.git] / yt_dlp / extractor / krasview.py
CommitLineData
8944ec01 1import json
8944ec01
S
2
3from .common import InfoExtractor
4from ..utils import (
5 int_or_none,
1e108029 6 js_to_json,
8944ec01
S
7)
8
9
10class KrasViewIE(InfoExtractor):
11 IE_DESC = 'Красвью'
1e108029 12 _VALID_URL = r'https?://krasview\.ru/(?:video|embed)/(?P<id>\d+)'
8944ec01
S
13
14 _TEST = {
15 'url': 'http://krasview.ru/video/512228',
16 'md5': '3b91003cf85fc5db277870c8ebd98eae',
17 'info_dict': {
18 'id': '512228',
19 'ext': 'mp4',
20 'title': 'Снег, лёд, заносы',
21 'description': 'Снято в городе Нягань, в Ханты-Мансийском автономном округе.',
22 'duration': 27,
ec85ded8 23 'thumbnail': r're:^https?://.*\.jpg',
8944ec01 24 },
ebbf078c
S
25 'params': {
26 'skip_download': 'Not accessible from Travis CI server',
27 },
8944ec01
S
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'))
2c2c06e3
S
43 width = int_or_none(self._og_search_property(
44 'video:width', webpage, 'video width', default=None))
45 height = int_or_none(self._og_search_property(
46 'video:height', webpage, 'video height', default=None))
8944ec01
S
47
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': title,
52 'description': description,
53 'thumbnail': thumbnail,
54 'duration': duration,
8944ec01
S
55 'width': width,
56 'height': height,
57 }