2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import determine_ext
10 class OnionStudiosIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:videos/[^/]+-|embed\?.*\bid=)(?P<id>\d+)(?!-)'
14 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
15 'md5': 'd4851405d31adfadf71cd7a487b765bb',
19 'title': 'Hannibal charges forward, stops for a cocktail',
20 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 'uploader': 'The A.V. Club',
23 'uploader_id': 'TheAVClub',
26 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
27 'only_matching': True,
31 def _extract_url(webpage):
33 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/embed.+?)\1', webpage)
35 return mobj.group('url')
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
40 webpage = self._download_webpage(
41 'http://www.onionstudios.com/embed?id=%s' % video_id, video_id)
44 for src in re.findall(r'<source[^>]+src="([^"]+)"', webpage):
45 if determine_ext(src) != 'm3u8': # m3u8 always results in 403
49 self._sort_formats(formats)
51 title = self._search_regex(
52 r'share_title\s*=\s*(["\'])(?P<title>[^\1]+?)\1',
53 webpage, 'title', group='title')
54 description = self._search_regex(
55 r'share_description\s*=\s*(["\'])(?P<description>[^\1]+?)\1',
56 webpage, 'description', default=None, group='description')
57 thumbnail = self._search_regex(
58 r'poster\s*=\s*(["\'])(?P<thumbnail>[^\1]+?)\1',
59 webpage, 'thumbnail', default=False, group='thumbnail')
61 uploader_id = self._search_regex(
62 r'twitter_handle\s*=\s*(["\'])(?P<uploader_id>[^\1]+?)\1',
63 webpage, 'uploader id', fatal=False, group='uploader_id')
64 uploader = self._search_regex(
65 r'window\.channelName\s*=\s*(["\'])Embedded:(?P<uploader>[^\1]+?)\1',
66 webpage, 'uploader', default=False, group='uploader')
71 'description': description,
72 'thumbnail': thumbnail,
74 'uploader_id': uploader_id,