1 from __future__ import unicode_literals
3 from .common import InfoExtractor
4 from ..utils import js_to_json
7 class RottenTomatoesIE(InfoExtractor):
8 _VALID_URL = r'https?://www\.rottentomatoes\.com/m/[^/]+/trailers/(?P<id>\d+)'
11 'url': 'http://www.rottentomatoes.com/m/toy_story_3/trailers/11028566/',
15 'title': 'Toy Story 3',
16 'thumbnail': 're:^https?://.*\.jpg$',
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
24 params = self._parse_json(
25 self._search_regex(r'(?s)RTVideo\(({.+?})\);', webpage, 'player parameters'),
26 video_id, transform_source=lambda s: js_to_json(s.replace('window.location.href', '""')))
29 if params.get('urlHLS'):
30 formats.extend(self._extract_m3u8_formats(
31 params['urlHLS'], video_id, ext='mp4',
32 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
33 if params.get('urlMP4'):
35 'url': params['urlMP4'],
38 self._sort_formats(formats)
42 'title': self._og_search_title(webpage),
44 'thumbnail': params.get('thumbnailImg'),