]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/onionstudios.py
[ie/youtube] Extract upload timestamp if available (#9856)
[yt-dlp.git] / yt_dlp / extractor / onionstudios.py
CommitLineData
f843300f 1from .common import InfoExtractor
55adb63e
RA
2from ..compat import compat_str
3from ..utils import js_to_json
f843300f
S
4
5
6class OnionStudiosIE(InfoExtractor):
b0def2c2 7 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
bfd973ec 8 _EMBED_REGEX = [r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1']
f843300f
S
9
10 _TESTS = [{
11 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
d64ec124 12 'md5': '5a118d466d62b5cd03647cf2c593977f',
f843300f 13 'info_dict': {
55adb63e 14 'id': '3459881',
f843300f
S
15 'ext': 'mp4',
16 'title': 'Hannibal charges forward, stops for a cocktail',
d64ec124 17 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
ec85ded8 18 'thumbnail': r're:^https?://.*\.jpg$',
d64ec124
RA
19 'uploader': 'a.v. club',
20 'upload_date': '20150619',
21 'timestamp': 1434728546,
f843300f
S
22 },
23 }, {
24 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
25 'only_matching': True,
b0def2c2
RA
26 }, {
27 'url': 'http://www.onionstudios.com/video/6139.json',
28 'only_matching': True,
f843300f
S
29 }]
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33
d64ec124
RA
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'])
55adb63e
RA
40 return self.url_result(
41 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id,
42 'KinjaEmbed', mcp_id)