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 def _real_extract(self,url):
26 mobj = re.match(self._VALID_URL, url)
28 webpage_url = u'http://' + mobj.group('url')
29 webpage = self._download_webpage(webpage_url, None) # Don't know video id yet
30 video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
31 video_id = self._html_search_regex(r'src="http://player\.screenwavemedia\.com/play/embed\.php\?id=(?P<video_id>.+?)"',
33 video_title = self._html_search_regex(r'<h1 class="entry-title">(?P<title>.+?)</h1>[^<]*</div>',
35 video_description = self._html_search_regex(r'<div class="entry-content">(?P<description>.+?)</div>',
36 webpage, u'description', flags=re.DOTALL, fatal=False)
38 playerdata_url = u'http://player.screenwavemedia.com/play/player.php?id=' + video_id
39 playerdata = self._download_webpage(playerdata_url, video_id)
40 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\'',
41 playerdata, u'base_url')
42 base_url += '/Cinemassacre/'
43 # The file names in playerdata are wrong for some videos???
44 sd_file = 'Cinemassacre-%s_high.mp4' % video_id
45 hd_file = 'Cinemassacre-%s.mp4' % video_id
46 video_thumbnail = 'http://image.screenwavemedia.com/Cinemassacre/Cinemassacre-%s_thumb_640x360.jpg' % video_id
50 'url': base_url + hd_file,
54 'description': video_description,
55 'upload_date': video_date,
56 'thumbnail': video_thumbnail,
60 'url': base_url + sd_file,
64 'description': video_description,
65 'upload_date': video_date,
66 'thumbnail': video_thumbnail,
69 if self._downloader.params.get('listformats', None):
70 self._print_formats(formats)
73 req_format = self._downloader.params.get('format', 'best')
74 self.to_screen(u'Format: %s' % req_format)
76 if req_format is None or req_format == 'best':
78 elif req_format == 'worst':
80 elif req_format in ('-1', 'all'):
83 format = self._specific( req_format, formats )
85 raise ExtractorError(u'Requested format not available')
88 def _print_formats(self, formats):
89 """Print all available formats"""
90 print(u'Available formats:')
91 print(u'ext\t\tformat')
92 print(u'---------------------------------')
93 for format in formats:
94 print(u'%s\t\t%s' % (format['ext'], format['format']))
96 def _specific(self, req_format, formats):
98 if x["format"] == req_format: