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.

85 lines
3.1 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})/(?P<display_id>[^?#/]+)'
  10. _TESTS = [
  11. {
  12. 'url': 'http://cinemassacre.com/2012/11/10/avgn-the-movie-trailer/',
  13. 'file': '19911.mp4',
  14. 'md5': '782f8504ca95a0eba8fc9177c373eec7',
  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': 'dec39ee5118f8d9cc067f45f9cbe3a35',
  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. display_id = mobj.group('display_id')
  34. webpage = self._download_webpage(url, display_id)
  35. video_date = mobj.group('date_Y') + mobj.group('date_m') + mobj.group('date_d')
  36. mobj = re.search(r'src="(?P<embed_url>http://player\.screenwavemedia\.com/play/[a-zA-Z]+\.php\?id=(?:Cinemassacre-)?(?P<video_id>.+?))"', webpage)
  37. if not mobj:
  38. raise ExtractorError('Can\'t extract embed url and video id')
  39. playerdata_url = mobj.group('embed_url')
  40. video_id = mobj.group('video_id')
  41. video_title = self._html_search_regex(
  42. r'<title>(?P<title>.+?)\|', webpage, 'title')
  43. video_description = self._html_search_regex(
  44. r'<div class="entry-content">(?P<description>.+?)</div>',
  45. webpage, 'description', flags=re.DOTALL, fatal=False)
  46. playerdata = self._download_webpage(playerdata_url, video_id)
  47. sd_url = self._html_search_regex(r'file: \'([^\']+)\', label: \'SD\'', playerdata, 'sd_file')
  48. hd_url = self._html_search_regex(
  49. r'file: \'([^\']+)\', label: \'HD\'', playerdata, 'hd_file',
  50. default=None)
  51. video_thumbnail = self._html_search_regex(r'image: \'(?P<thumbnail>[^\']+)\'', playerdata, 'thumbnail', fatal=False)
  52. formats = [{
  53. 'url': sd_url,
  54. 'ext': 'mp4',
  55. 'format': 'sd',
  56. 'format_id': 'sd',
  57. 'quality': 1,
  58. }]
  59. if hd_url:
  60. formats.append({
  61. 'url': hd_url,
  62. 'ext': 'mp4',
  63. 'format': 'hd',
  64. 'format_id': 'hd',
  65. 'quality': 2,
  66. })
  67. self._sort_formats(formats)
  68. return {
  69. 'id': video_id,
  70. 'title': video_title,
  71. 'formats': formats,
  72. 'description': video_description,
  73. 'upload_date': video_date,
  74. 'thumbnail': video_thumbnail,
  75. }