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.

78 lines
2.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. compat_str,
  7. clean_html,
  8. )
  9. class MovieClipsIE(InfoExtractor):
  10. _VALID_URL = r'https?://movieclips\.com/(?P<id>[\da-zA-Z]+)(?:-(?P<display_id>[\da-z-]+))?'
  11. _TEST = {
  12. 'url': 'http://movieclips.com/Wy7ZU-my-week-with-marilyn-movie-do-you-love-me/',
  13. 'info_dict': {
  14. 'id': 'Wy7ZU',
  15. 'display_id': 'my-week-with-marilyn-movie-do-you-love-me',
  16. 'ext': 'mp4',
  17. 'title': 'My Week with Marilyn - Do You Love Me?',
  18. 'description': 'md5:e86795bd332fe3cff461e7c8dc542acb',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. },
  21. 'params': {
  22. # rtmp download
  23. 'skip_download': True,
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. display_id = mobj.group('display_id')
  30. show_id = display_id or video_id
  31. config = self._download_xml(
  32. 'http://config.movieclips.com/player/config/%s' % video_id,
  33. show_id, 'Downloading player config')
  34. if config.find('./country-region').text == 'false':
  35. raise ExtractorError(
  36. '%s said: %s' % (self.IE_NAME, config.find('./region_alert').text), expected=True)
  37. properties = config.find('./video/properties')
  38. smil_file = properties.attrib['smil_file']
  39. smil = self._download_xml(smil_file, show_id, 'Downloading SMIL')
  40. base_url = smil.find('./head/meta').attrib['base']
  41. formats = []
  42. for video in smil.findall('./body/switch/video'):
  43. vbr = int(video.attrib['system-bitrate']) / 1000
  44. src = video.attrib['src']
  45. formats.append({
  46. 'url': base_url,
  47. 'play_path': src,
  48. 'ext': src.split(':')[0],
  49. 'vbr': vbr,
  50. 'format_id': '%dk' % vbr,
  51. })
  52. self._sort_formats(formats)
  53. title = '%s - %s' % (properties.attrib['clip_movie_title'], properties.attrib['clip_title'])
  54. description = clean_html(compat_str(properties.attrib['clip_description']))
  55. thumbnail = properties.attrib['image']
  56. categories = properties.attrib['clip_categories'].split(',')
  57. return {
  58. 'id': video_id,
  59. 'display_id': display_id,
  60. 'title': title,
  61. 'description': description,
  62. 'thumbnail': thumbnail,
  63. 'categories': categories,
  64. 'formats': formats,
  65. }