]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cinemassacre.py
   4 from .common 
import InfoExtractor
 
  10 class CinemassacreIE(InfoExtractor
): 
  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.flv', 
  16             u
'upload_date': u
'20121110', 
  17             u
'title': u
'“Angry Video Game Nerd: The Movie” – Trailer', 
  18             u
'description': u
'md5:fb87405fcb42a331742a0dce2708560b', 
  22             u
'skip_download': True, 
  26         u
'url': u
'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940', 
  27         u
'file': u
'521be8ef82b16.flv', 
  29             u
'upload_date': u
'20131002', 
  30             u
'title': u
'The Mummy’s Hand (1940)', 
  34             u
'skip_download': True, 
  38     def _real_extract(self
, url
): 
  39         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  41         webpage_url 
= u
'http://' + mobj
.group('url') 
  42         webpage 
= self
._download
_webpage
(webpage_url
, None) # Don't know video id yet 
  43         video_date 
= mobj
.group('date_Y') + mobj
.group('date_m') + mobj
.group('date_d') 
  44         mobj 
= re
.search(r
'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage
) 
  46             raise ExtractorError(u
'Can\'t extract embed url and video id') 
  47         playerdata_url 
= mobj
.group(u
'embed_url') 
  48         video_id 
= mobj
.group(u
'video_id') 
  50         video_title 
= self
._html
_search
_regex
(r
'<title>(?P<title>.+?)\|', 
  52         video_description 
= self
._html
_search
_regex
(r
'<div class="entry-content">(?P<description>.+?)</div>', 
  53             webpage
, u
'description', flags
=re
.DOTALL
, fatal
=False) 
  54         if len(video_description
) == 0: 
  55             video_description 
= None 
  57         playerdata 
= self
._download
_webpage
(playerdata_url
, video_id
) 
  58         url 
= self
._html
_search
_regex
(r
'\'streamer
\': \'(?P
<url
>[^
\']+)\'', playerdata, u'url
') 
  60         sd_file = self._html_search_regex(r'\'file\': \'(?P
<sd_file
>[^
\']+)\'', playerdata, u'sd_file
') 
  61         hd_file = self._html_search_regex(r'\'?
file\'?
: "(?P<hd_file>[^"]+)"', playerdata, u'hd_file') 
  62         video_thumbnail = self._html_search_regex(r'\'image\': \'(?P<thumbnail>[^\']+)\'', playerdata, u'thumbnail', fatal=False) 
  67                 'play_path': 'mp4:' + sd_file, 
  68                 'rtmp_live': True, # workaround 
  75                 'play_path': 'mp4:' + hd_file, 
  76                 'rtmp_live': True, # workaround 
  87             'description': video_description, 
  88             'upload_date': video_date, 
  89             'thumbnail': video_thumbnail,