You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.3 KiB

  1. # encoding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. )
  7. class CinemassacreIE(InfoExtractor):
  8. _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})/.+?)(?:[/?].*)?'
  9. _TESTS = [{
  10. u'url': u'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
  11. u'file': u'19911.flv',
  12. u'info_dict': {
  13. u'upload_date': u'20121110',
  14. u'title': u'“Angry Video Game Nerd: The Movie” – Trailer',
  15. u'description': u'md5:fb87405fcb42a331742a0dce2708560b',
  16. },
  17. u'params': {
  18. # rtmp download
  19. u'skip_download': True,
  20. },
  21. },
  22. {
  23. u'url': u'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
  24. u'file': u'521be8ef82b16.flv',
  25. u'info_dict': {
  26. u'upload_date': u'20131002',
  27. u'title': u'The Mummy’s Hand (1940)',
  28. },
  29. u'params': {
  30. # rtmp download
  31. u'skip_download': True,
  32. },
  33. }]
  34. def _real_extract(self, url):
  35. mobj = re.match(self._VALID_URL, url)
  36. webpage_url = u'http://' + mobj.group('url')
  37. webpage = self._download_webpage(webpage_url, None) # Don't know video id yet
  38. video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
  39. mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/(?:embed|player)\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
  40. if not mobj:
  41. raise ExtractorError(u'Can\'t extract embed url and video id')
  42. playerdata_url = mobj.group(u'embed_url')
  43. video_id = mobj.group(u'video_id')
  44. video_title = self._html_search_regex(r'<title>(?P<title>.+?)\|',
  45. webpage, u'title')
  46. video_description = self._html_search_regex(r'<div class="entry-content">(?P<description>.+?)</div>',
  47. webpage, u'description', flags=re.DOTALL, fatal=False)
  48. if len(video_description) == 0:
  49. video_description = None
  50. playerdata = self._download_webpage(playerdata_url, video_id)
  51. base_url = self._html_search_regex(r'\'streamer\': \'(?P<base_url>rtmp://.*?)/(?:vod|Cinemassacre)\'',
  52. playerdata, u'base_url')
  53. base_url += '/Cinemassacre/'
  54. # Important: The file names in playerdata are not used by the player and even wrong for some videos
  55. sd_file = 'Cinemassacre-%s_high.mp4' % video_id
  56. hd_file = 'Cinemassacre-%s.mp4' % video_id
  57. video_thumbnail = 'http://image.screenwavemedia.com/Cinemassacre/Cinemassacre-%s_thumb_640x360.jpg' % video_id
  58. formats = [
  59. {
  60. 'url': base_url + sd_file,
  61. 'ext': 'flv',
  62. 'format': 'sd',
  63. 'format_id': 'sd',
  64. },
  65. {
  66. 'url': base_url + hd_file,
  67. 'ext': 'flv',
  68. 'format': 'hd',
  69. 'format_id': 'hd',
  70. },
  71. ]
  72. info = {
  73. 'id': video_id,
  74. 'title': video_title,
  75. 'formats': formats,
  76. 'description': video_description,
  77. 'upload_date': video_date,
  78. 'thumbnail': video_thumbnail,
  79. }
  80. # TODO: Remove when #980 has been merged
  81. info.update(formats[-1])
  82. return info