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