[ie/twitter:spaces] Support video spaces (#10789)
[yt-dlp3.git] / yt_dlp / extractor / onionstudios.py
blob7e30b2d33dccbf2d90931f3e2c947356579c73fb
1 from .common import InfoExtractor
2 from ..utils import js_to_json
5 class OnionStudiosIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
7 _EMBED_REGEX = [r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1']
9 _TESTS = [{
10 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
11 'md5': '5a118d466d62b5cd03647cf2c593977f',
12 'info_dict': {
13 'id': '3459881',
14 'ext': 'mp4',
15 'title': 'Hannibal charges forward, stops for a cocktail',
16 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
17 'thumbnail': r're:^https?://.*\.jpg$',
18 'uploader': 'a.v. club',
19 'upload_date': '20150619',
20 'timestamp': 1434728546,
22 }, {
23 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
24 'only_matching': True,
25 }, {
26 'url': 'http://www.onionstudios.com/video/6139.json',
27 'only_matching': True,
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
33 webpage = self._download_webpage(
34 'http://onionstudios.com/embed/dc94dc2899fe644c0e7241fa04c1b732.js',
35 video_id)
36 mcp_id = str(self._parse_json(self._search_regex(
37 r'window\.mcpMapping\s*=\s*({.+?});', webpage,
38 'MCP Mapping'), video_id, js_to_json)[video_id]['mcp_id'])
39 return self.url_result(
40 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id,
41 'KinjaEmbed', mcp_id)