4 from .common import InfoExtractor
9 class CinemassacreIE(InfoExtractor):
10 """Information Extractor for Cinemassacre"""
11 _VALID_URL = r'(?:http://)?(?:www\.)?(?P<url>cinemassacre\.com/(?P<date_Y>[0-9]{4})/(?P<date_m>[0-9]{2})/(?P<date_d>[0-9]{2})/.+?)(?:[/?].*)?'
13 u'url': u'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
14 u'file': u'19911.mp4',
16 u'upload_date': u'20121110',
17 u'title': u'“Angry Video Game Nerd: The Movie” – Trailer',
18 #u'description': u'“Angry Video Game Nerd: The Movie” is...', # Description is too long
21 u'skip_download': True,
25 u'url': u'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
26 u'file': u'521be8ef82b16.mp4',
28 u'upload_date': u'20131002',
29 u'title': u'The Mummy’s Hand (1940)',
32 u'skip_download': True,
36 def _real_extract(self,url):
37 mobj = re.match(self._VALID_URL, url)
39 webpage_url = u'http://' + mobj.group('url')
40 webpage = self._download_webpage(webpage_url, None) # Don't know video id yet
41 video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
42 mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/(?:embed|player)\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
44 raise ExtractorError(u'Can\'t extract embed url and video id')
45 playerdata_url = mobj.group(u'embed_url')
46 video_id = mobj.group(u'video_id')
48 video_title = self._html_search_regex(r'<title>(?P<title>.+?)\|',
50 video_description = self._html_search_regex(r'<div class="entry-content">(?P<description>.+?)</div>',
51 webpage, u'description', flags=re.DOTALL, fatal=False)
52 if len(video_description) == 0:
53 video_description = None
55 playerdata = self._download_webpage(playerdata_url, video_id)
56 base_url = self._html_search_regex(r'\'streamer\': \'(?P<base_url>rtmp://[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/(?:vod|Cinemassacre)\'',
57 playerdata, u'base_url')
58 base_url += '/Cinemassacre/'
59 # Important: The file names in playerdata are not used by the player and even wrong for some videos
60 sd_file = 'Cinemassacre-%s_high.mp4' % video_id
61 hd_file = 'Cinemassacre-%s.mp4' % video_id
62 video_thumbnail = 'http://image.screenwavemedia.com/Cinemassacre/Cinemassacre-%s_thumb_640x360.jpg' % video_id
66 'url': base_url + hd_file,
70 'description': video_description,
71 'upload_date': video_date,
72 'thumbnail': video_thumbnail,
76 'url': base_url + sd_file,
80 'description': video_description,
81 'upload_date': video_date,
82 'thumbnail': video_thumbnail,
85 if self._downloader.params.get('listformats', None):
86 self._print_formats(formats)
89 req_format = self._downloader.params.get('format', 'best')
90 self.to_screen(u'Format: %s' % req_format)
92 if req_format is None or req_format == 'best':
94 elif req_format == 'worst':
96 elif req_format in ('-1', 'all'):
99 format = self._specific( req_format, formats )
101 raise ExtractorError(u'Requested format not available')
104 def _print_formats(self, formats):
105 """Print all available formats"""
106 print(u'Available formats:')
107 print(u'ext\t\tformat')
108 print(u'---------------------------------')
109 for format in formats:
110 print(u'%s\t\t%s' % (format['ext'], format['format']))
112 def _specific(self, req_format, formats):
114 if x["format"] == req_format: