]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/streamable.py
3 from .common
import InfoExtractor
13 class StreamableIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://streamable\.com/(?:[es]/)?(?P<id>\w+)'
17 'url': 'https://streamable.com/dnd1',
18 'md5': '3e3bc5ca088b48c2d436529b64397fef',
22 'title': 'Mikel Oiarzabal scores to make it 0-3 for La Real against Espanyol',
23 'thumbnail': r
're:https?://.*\.jpg$',
24 'uploader': 'teabaker',
25 'timestamp': 1454964157.35115,
26 'upload_date': '20160208',
31 # older video without bitrate, width/height, codecs, etc. info
33 'url': 'https://streamable.com/moo',
34 'md5': '2cf6923639b87fba3279ad0df3a64e73',
38 'title': '"Please don\'t eat me!"',
39 'thumbnail': r
're:https?://.*\.jpg$',
40 'timestamp': 1426115495,
41 'upload_date': '20150311',
47 'url': 'https://streamable.com/e/dnd1',
48 'only_matching': True,
51 'url': 'https://streamable.com/s/okkqk/drxjds',
52 'only_matching': True,
57 def _extract_url(webpage
):
59 r
'<iframe[^>]+src=(?P<q1>[\'"])(?P<src>(?:https?:)?//streamable\.com/(?:(?!\1).+))(?P=q1)',
62 return mobj.group('src')
64 def _real_extract(self, url):
65 video_id = self._match_id(url)
67 # Note: Using the ajax API, as the public Streamable API doesn't seem
68 # to return video info like the title properly sometimes, and doesn't
69 # include info like the video duration
70 video = self._download_json(
71 'https://ajax.streamable.com/videos/%s' % video_id, video_id)
74 # 0 The video is being uploaded
75 # 1 The video is being processed
76 # 2 The video has at least one file ready
77 # 3 The video is unavailable due to an error
78 status = video.get('status')
81 'This video is currently unavailable. It may still be uploading or processing.',
84 title = video.get('reddit_title') or video['title']
87 for key, info in video['files'].items():
88 if not info.get('url'):
92 'url': self._proto_relative_url(info['url']),
93 'width': int_or_none(info.get('width')),
94 'height': int_or_none(info.get('height')),
95 'filesize': int_or_none(info.get('size')),
96 'fps': int_or_none(info.get('framerate')),
97 'vbr': float_or_none(info.get('bitrate'), 1000),
98 'vcodec': parse_codecs(try_get(info, lambda x: x['input_metadata']['video_codec_name'])).get('vcodec'),
99 'acodec': parse_codecs(try_get(info, lambda x: x['input_metadata']['audio_codec_name'])).get('acodec'),
101 self._sort_formats(formats)
106 'description': video.get('description'),
107 'thumbnail': self._proto_relative_url(video.get('thumbnail_url')),
108 'uploader': video.get('owner', {}).get('user_name'),
109 'timestamp': float_or_none(video.get('date_added')),
110 'duration': float_or_none(video.get('duration')),
111 'view_count': int_or_none(video.get('plays')),