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.

90 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/[a-zA-Z]+\.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. url = self._html_search_regex(r'\'streamer\': \'(?P<url>[^\']+)\'', playerdata, u'url')
  52. sd_file = self._html_search_regex(r'\'file\': \'(?P<sd_file>[^\']+)\'', playerdata, u'sd_file')
  53. hd_file = self._html_search_regex(r'\'?file\'?: "(?P<hd_file>[^"]+)"', playerdata, u'hd_file')
  54. video_thumbnail = self._html_search_regex(r'\'image\': \'(?P<thumbnail>[^\']+)\'', playerdata, u'thumbnail', fatal=False)
  55. formats = [
  56. {
  57. 'url': url,
  58. 'play_path': 'mp4:' + sd_file,
  59. 'rtmp_live': True, # workaround
  60. 'ext': 'flv',
  61. 'format': 'sd',
  62. 'format_id': 'sd',
  63. },
  64. {
  65. 'url': url,
  66. 'play_path': 'mp4:' + hd_file,
  67. 'rtmp_live': True, # workaround
  68. 'ext': 'flv',
  69. 'format': 'hd',
  70. 'format_id': 'hd',
  71. },
  72. ]
  73. return {
  74. 'id': video_id,
  75. 'title': video_title,
  76. 'formats': formats,
  77. 'description': video_description,
  78. 'upload_date': video_date,
  79. 'thumbnail': video_thumbnail,
  80. }