]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/onionstudios.py
Update changelog.
[youtubedl] / youtube_dl / extractor / onionstudios.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..compat import compat_str
8 from ..utils import js_to_json
9
10
11 class OnionStudiosIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
13
14 _TESTS = [{
15 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
16 'md5': '5a118d466d62b5cd03647cf2c593977f',
17 'info_dict': {
18 'id': '3459881',
19 'ext': 'mp4',
20 'title': 'Hannibal charges forward, stops for a cocktail',
21 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'uploader': 'a.v. club',
24 'upload_date': '20150619',
25 'timestamp': 1434728546,
26 },
27 }, {
28 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
29 'only_matching': True,
30 }, {
31 'url': 'http://www.onionstudios.com/video/6139.json',
32 'only_matching': True,
33 }]
34
35 @staticmethod
36 def _extract_url(webpage):
37 mobj = re.search(
38 r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1', webpage)
39 if mobj:
40 return mobj.group('url')
41
42 def _real_extract(self, url):
43 video_id = self._match_id(url)
44
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'])
51 return self.url_result(
52 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id,
53 'KinjaEmbed', mcp_id)