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.

81 lines
3.0 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. )
  8. class CinemassacreIE(InfoExtractor):
  9. _VALID_URL = r'http://(?:www\.)?cinemassacre\.com/(?P<date_Y>[0-9]{4})/(?P<date_m>[0-9]{2})/(?P<date_d>[0-9]{2})/.+?'
  10. _TESTS = [
  11. {
  12. 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
  13. 'file': '19911.mp4',
  14. 'md5': 'fde81fbafaee331785f58cd6c0d46190',
  15. 'info_dict': {
  16. 'upload_date': '20121110',
  17. 'title': '“Angry Video Game Nerd: The Movie” – Trailer',
  18. 'description': 'md5:fb87405fcb42a331742a0dce2708560b',
  19. },
  20. },
  21. {
  22. 'url': 'http://cinemassacre.com/2013/10/02/the-mummys-hand-1940',
  23. 'file': '521be8ef82b16.mp4',
  24. 'md5': 'd72f10cd39eac4215048f62ab477a511',
  25. 'info_dict': {
  26. 'upload_date': '20131002',
  27. 'title': 'The Mummy’s Hand (1940)',
  28. },
  29. }
  30. ]
  31. def _real_extract(self, url):
  32. mobj = re.match(self._VALID_URL, url)
  33. webpage = self._download_webpage(url, None) # Don't know video id yet
  34. video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
  35. mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
  36. if not mobj:
  37. raise ExtractorError('Can\'t extract embed url and video id')
  38. playerdata_url = mobj.group('embed_url')
  39. video_id = mobj.group('video_id')
  40. video_title = self._html_search_regex(r'<title>(?P<title>.+?)\|',
  41. webpage, 'title')
  42. video_description = self._html_search_regex(r'<div class="entry-content">(?P<description>.+?)</div>',
  43. webpage, 'description', flags=re.DOTALL, fatal=False)
  44. if len(video_description) == 0:
  45. video_description = None
  46. playerdata = self._download_webpage(playerdata_url, video_id)
  47. sd_url = self._html_search_regex(r'file: \'(?P<sd_file>[^\']+)\', label: \'SD\'', playerdata, 'sd_file')
  48. hd_url = self._html_search_regex(r'file: \'(?P<hd_file>[^\']+)\', label: \'HD\'', playerdata, 'hd_file')
  49. video_thumbnail = self._html_search_regex(r'image: \'(?P<thumbnail>[^\']+)\'', playerdata, 'thumbnail', fatal=False)
  50. formats = [
  51. {
  52. 'url': sd_url,
  53. 'ext': 'mp4',
  54. 'format': 'sd',
  55. 'format_id': 'sd',
  56. },
  57. {
  58. 'url': hd_url,
  59. 'ext': 'mp4',
  60. 'format': 'hd',
  61. 'format_id': 'hd',
  62. },
  63. ]
  64. return {
  65. 'id': video_id,
  66. 'title': video_title,
  67. 'formats': formats,
  68. 'description': video_description,
  69. 'upload_date': video_date,
  70. 'thumbnail': video_thumbnail,
  71. }