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.

80 lines
2.6 KiB

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