1 from __future__ import unicode_literals
15 class ScreenJunkiesIE(InfoExtractor):
16 _VALID_URL = r'http://www.screenjunkies.com/video/(.+-(?P<id>\d+)|.+)'
19 'url': 'http://www.screenjunkies.com/video/best-quentin-tarantino-movie-2841915',
23 'title': 'Best Quentin Tarantino Movie',
26 'url': 'http://www.screenjunkies.com/video/honest-trailers-the-dark-knight',
30 'title': "Honest Trailers - 'The Dark Knight'",
33 'url': 'http://www.screenjunkies.com/video/knocking-dead-ep-1-the-show-so-far-3003285',
34 'only_matching': True,
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
40 if not video_id: # Older urls didn't have the id in them, but we can grab it manually
41 webpage = self._download_webpage(url, url)
42 video_id = self._html_search_regex(r'src="/embed/(\d+)"', webpage, 'video id')
44 webpage = self._download_webpage('http://www.screenjunkies.com/embed/%s' %video_id, video_id)
45 video_vars_str = self._html_search_regex(r'embedVars = (\{.+\})\s*</script>', webpage, 'video variables', flags=re.S)
46 video_vars = self._parse_json(video_vars_str, video_id)
48 # TODO: Figure out required cookies
49 if video_vars['subscriptionLevel'] > 0:
50 raise ExtractorError('This video requires ScreenJunkiesPlus', expected=True)
53 for f in video_vars['media']:
54 if not f['mediaPurpose'] == 'play':
59 'width': int_or_none(f.get('width')),
60 'height': int_or_none(f.get('height')),
61 'tbr': int_or_none(f.get('bitRate')),
64 self._sort_formats(formats)
68 'title': video_vars['contentName'],
70 'duration': int_or_none(video_vars.get('videoLengthInSeconds')),
71 'thumbnail': video_vars.get('thumbUri'),
72 'tags': video_vars['tags'].split(',') if 'tags' in video_vars else [],