2 from __future__ import unicode_literals
5 from .common import InfoExtractor
11 class CinemassacreIE(InfoExtractor):
12 _VALID_URL = r'http://(?:www\.)?cinemassacre\.com/(?P<date_Y>[0-9]{4})/(?P<date_m>[0-9]{2})/(?P<date_d>[0-9]{2})/(?P<display_id>[^?#/]+)'
15 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
17 'md5': 'fde81fbafaee331785f58cd6c0d46190',
19 'upload_date': '20121110',
20 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
21 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
25 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
26 'file': '521be8ef82b16.mp4',
27 'md5': 'd72f10cd39eac4215048f62ab477a511',
29 'upload_date': '20131002',
30 'title': 'The Mummy’s Hand (1940)',
35 def _real_extract(self, url):
36 mobj = re.match(self._VALID_URL, url)
37 display_id = mobj.group('display_id')
39 webpage = self._download_webpage(url, display_id)
40 video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
41 mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
43 raise ExtractorError('Can\'t extract embed url and video id')
44 playerdata_url = mobj.group('embed_url')
45 video_id = mobj.group('video_id')
47 video_title = self._html_search_regex(
48 r'<title>(?P<title>.+?)\|', webpage, 'title')
49 video_description = self._html_search_regex(
50 r'<div class="entry-content">(?P<description>.+?)</div>',
51 webpage, 'description', flags=re.DOTALL, fatal=False)
53 playerdata = self._download_webpage(playerdata_url, video_id)
54 video_thumbnail = self._search_regex(r'image: \'(?P<thumbnail>[^\']+)\'', playerdata, 'thumbnail', fatal=False)
55 sd_url = self._search_regex(r'file: \'([^\']+)\', label: \'SD\'', playerdata, 'sd_file')
56 videolist_url = self._search_regex(r'file: \'([^\']+\.smil)\'}', playerdata, 'videolist_url')
58 videolist = self._download_webpage(videolist_url, video_id)
60 baseurl = sd_url[:sd_url.rfind('/')+1]
61 for match in re.finditer('<video src="mp4:(?P<file>[^"]+_(?P<format_id>[^"]+)\.[^"]+)" system-bitrate="(?P<br>\d+)"(?: width="(?P<width>\d+)" height="(?P<height>\d+)")?/>', videolist):
63 'url': baseurl + match.group('file'),
64 'format_id': match.group('format_id')
66 if match.group('width'):
68 'tbr': int(match.group('br')) // 1000,
69 'width': int(match.group('width')),
70 'height': int(match.group('height'))
74 'abr': int(match.group('br')) // 1000,
77 formats.append(format)
78 self._sort_formats(formats)
84 'description': video_description,
85 'upload_date': video_date,
86 'thumbnail': video_thumbnail,