2 from __future__ import unicode_literals
4 from .common import InfoExtractor
12 class StreamableIE(InfoExtractor):
13 _VALID_URL = r'https?://streamable\.com/(?:e/)?(?P<id>\w+)'
16 'url': 'https://streamable.com/dnd1',
17 'md5': '3e3bc5ca088b48c2d436529b64397fef',
21 'title': 'Mikel Oiarzabal scores to make it 0-3 for La Real against Espanyol',
22 'thumbnail': 're:https?://.*\.jpg$',
23 'uploader': 'teabaker',
24 'timestamp': 1454964157.35115,
25 'upload_date': '20160208',
30 # older video without bitrate, width/height, etc. info
32 'url': 'https://streamable.com/moo',
33 'md5': '2cf6923639b87fba3279ad0df3a64e73',
37 'title': '"Please don\'t eat me!"',
38 'thumbnail': 're:https?://.*\.jpg$',
39 'timestamp': 1426115495,
40 'upload_date': '20150311',
46 'url': 'https://streamable.com/e/dnd1',
47 'only_matching': True,
51 def _real_extract(self, url):
52 video_id = self._match_id(url)
54 # Note: Using the ajax API, as the public Streamable API doesn't seem
55 # to return video info like the title properly sometimes, and doesn't
56 # include info like the video duration
57 video = self._download_json(
58 'https://streamable.com/ajax/videos/%s' % video_id, video_id)
61 # 0 The video is being uploaded
62 # 1 The video is being processed
63 # 2 The video has at least one file ready
64 # 3 The video is unavailable due to an error
65 status = video.get('status')
68 'This video is currently unavailable. It may still be uploading or processing.',
71 title = video.get('reddit_title') or video['title']
74 for key, info in video['files'].items():
75 if not info.get('url'):
79 'url': self._proto_relative_url(info['url']),
80 'width': int_or_none(info.get('width')),
81 'height': int_or_none(info.get('height')),
82 'filesize': int_or_none(info.get('size')),
83 'fps': int_or_none(info.get('framerate')),
84 'vbr': float_or_none(info.get('bitrate'), 1000)
86 self._sort_formats(formats)
91 'description': video.get('description'),
92 'thumbnail': self._proto_relative_url(video.get('thumbnail_url')),
93 'uploader': video.get('owner', {}).get('user_name'),
94 'timestamp': float_or_none(video.get('date_added')),
95 'duration': float_or_none(video.get('duration')),
96 'view_count': int_or_none(video.get('plays')),