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