2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class CinemassacreIE(InfoExtractor):
14 _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>[^?#/]+)'
17 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
18 'md5': 'fde81fbafaee331785f58cd6c0d46190',
22 'upload_date': '20121110',
23 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
24 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
28 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
29 'md5': 'd72f10cd39eac4215048f62ab477a511',
31 'id': '521be8ef82b16',
33 'upload_date': '20131002',
34 'title': 'The Mummy’s Hand (1940)',
39 def _real_extract(self, url):
40 mobj = re.match(self._VALID_URL, url)
41 display_id = mobj.group('display_id')
43 webpage = self._download_webpage(url, display_id)
44 video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
45 mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?[^"]*\bid=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
47 raise ExtractorError('Can\'t extract embed url and video id')
48 playerdata_url = mobj.group('embed_url')
49 video_id = mobj.group('video_id')
51 video_title = self._html_search_regex(
52 r'<title>(?P<title>.+?)\|', webpage, 'title')
53 video_description = self._html_search_regex(
54 r'<div class="entry-content">(?P<description>.+?)</div>',
55 webpage, 'description', flags=re.DOTALL, fatal=False)
56 video_thumbnail = self._og_search_thumbnail(webpage)
58 playerdata = self._download_webpage(playerdata_url, video_id, 'Downloading player webpage')
60 vidurl = self._search_regex(
61 r'\'vidurl\'\s*:\s*"([^\']+)"', playerdata, 'vidurl').replace('\\/', '/')
62 vidid = self._search_regex(
63 r'\'vidid\'\s*:\s*"([^\']+)"', playerdata, 'vidid')
64 videoserver = self._html_search_regex(
65 r"'videoserver'\s*:\s*'([^']+)'", playerdata, 'videoserver')
67 videolist_url = 'http://%s/vod/smil:%s.smil/jwplayer.smil' % (videoserver, vidid)
68 videolist = self._download_xml(videolist_url, video_id, 'Downloading videolist XML')
71 baseurl = vidurl[:vidurl.rfind('/')+1]
72 for video in videolist.findall('.//video'):
73 src = video.get('src')
76 file_ = src.partition(':')[-1]
77 width = int_or_none(video.get('width'))
78 height = int_or_none(video.get('height'))
79 bitrate = int_or_none(video.get('system-bitrate'))
81 'url': baseurl + file_,
82 'format_id': src.rpartition('.')[0].rpartition('_')[-1],
86 'tbr': bitrate // 1000 if bitrate else None,
92 'abr': bitrate // 1000 if bitrate else None,
95 formats.append(format)
96 self._sort_formats(formats)
100 'title': video_title,
102 'description': video_description,
103 'upload_date': video_date,
104 'thumbnail': video_thumbnail,