]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/onionstudios.py
[paramountplus] Separate extractor and fix some titles (#652)
[yt-dlp.git] / yt_dlp / extractor / onionstudios.py
CommitLineData
f843300f
S
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
55adb63e
RA
7from ..compat import compat_str
8from ..utils import js_to_json
f843300f
S
9
10
11class OnionStudiosIE(InfoExtractor):
b0def2c2 12 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
f843300f
S
13
14 _TESTS = [{
15 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
d64ec124 16 'md5': '5a118d466d62b5cd03647cf2c593977f',
f843300f 17 'info_dict': {
55adb63e 18 'id': '3459881',
f843300f
S
19 'ext': 'mp4',
20 'title': 'Hannibal charges forward, stops for a cocktail',
d64ec124 21 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
ec85ded8 22 'thumbnail': r're:^https?://.*\.jpg$',
d64ec124
RA
23 'uploader': 'a.v. club',
24 'upload_date': '20150619',
25 'timestamp': 1434728546,
f843300f
S
26 },
27 }, {
28 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
29 'only_matching': True,
b0def2c2
RA
30 }, {
31 'url': 'http://www.onionstudios.com/video/6139.json',
32 'only_matching': True,
f843300f
S
33 }]
34
d4f58034
S
35 @staticmethod
36 def _extract_url(webpage):
37 mobj = re.search(
b0def2c2 38 r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1', webpage)
d4f58034
S
39 if mobj:
40 return mobj.group('url')
41
f843300f
S
42 def _real_extract(self, url):
43 video_id = self._match_id(url)
44
d64ec124
RA
45 webpage = self._download_webpage(
46 'http://onionstudios.com/embed/dc94dc2899fe644c0e7241fa04c1b732.js',
47 video_id)
48 mcp_id = compat_str(self._parse_json(self._search_regex(
49 r'window\.mcpMapping\s*=\s*({.+?});', webpage,
50 'MCP Mapping'), video_id, js_to_json)[video_id]['mcp_id'])
55adb63e
RA
51 return self.url_result(
52 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id,
53 'KinjaEmbed', mcp_id)