]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/vimple.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / vimple.py
CommitLineData
0d933b2a 1from .common import InfoExtractor
45ead916 2from ..utils import int_or_none
0d933b2a 3
e66ab17a 4
675e9f22
S
5class SprutoBaseIE(InfoExtractor):
6 def _extract_spruto(self, spruto, video_id):
7 playlist = spruto['playlist'][0]
8 title = playlist['title']
9 video_id = playlist.get('videoId') or video_id
10 thumbnail = playlist.get('posterUrl') or playlist.get('thumbnailUrl')
11 duration = int_or_none(playlist.get('duration'))
12
13 formats = [{
14 'url': f['url'],
15 } for f in playlist['video']]
675e9f22
S
16
17 return {
18 'id': video_id,
19 'title': title,
20 'thumbnail': thumbnail,
21 'duration': duration,
22 'formats': formats,
23 }
24
25
26class VimpleIE(SprutoBaseIE):
d8e7ef04 27 IE_DESC = 'Vimple - one-click video hosting'
091624f9
S
28 _VALID_URL = r'https?://(?:player\.vimple\.(?:ru|co)/iframe|vimple\.(?:ru|co))/(?P<id>[\da-f-]{32,36})'
29 _TESTS = [{
30 'url': 'http://vimple.ru/c0f6b1687dcd4000a97ebe70068039cf',
31 'md5': '2e750a330ed211d3fd41821c6ad9a279',
32 'info_dict': {
33 'id': 'c0f6b168-7dcd-4000-a97e-be70068039cf',
34 'ext': 'mp4',
35 'title': 'Sunset',
36 'duration': 20,
ec85ded8 37 'thumbnail': r're:https?://.*?\.jpg',
091624f9
S
38 },
39 }, {
40 'url': 'http://player.vimple.ru/iframe/52e1beec-1314-4a83-aeac-c61562eadbf9',
41 'only_matching': True,
42 }, {
43 'url': 'http://vimple.co/04506a053f124483b8fb05ed73899f19',
44 'only_matching': True,
45 }]
e66ab17a 46
0d933b2a 47 def _real_extract(self, url):
d8e7ef04 48 video_id = self._match_id(url)
e66ab17a 49
d8e7ef04
S
50 webpage = self._download_webpage(
51 'http://player.vimple.ru/iframe/%s' % video_id, video_id)
0d933b2a 52
675e9f22 53 spruto = self._parse_json(
d8e7ef04
S
54 self._search_regex(
55 r'sprutoData\s*:\s*({.+?}),\r\n', webpage, 'spruto data'),
675e9f22 56 video_id)
0d933b2a 57
675e9f22 58 return self._extract_spruto(spruto, video_id)