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