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.

42 lines
1.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_request,
  6. )
  7. class MovieClipsIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www.)?movieclips\.com/videos/(?P<id>[^/?#]+)'
  9. _TEST = {
  10. 'url': 'http://www.movieclips.com/videos/warcraft-trailer-1-561180739597?autoPlay=true&playlistId=5',
  11. 'info_dict': {
  12. 'id': 'pKIGmG83AqD9',
  13. 'display_id': 'warcraft-trailer-1-561180739597',
  14. 'ext': 'mp4',
  15. 'title': 'Warcraft Trailer 1',
  16. 'description': 'Watch Trailer 1 from Warcraft (2016). Legendary’s WARCRAFT is a 3D epic adventure of world-colliding conflict based.',
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. },
  19. 'add_ie': ['ThePlatform'],
  20. }
  21. def _real_extract(self, url):
  22. display_id = self._match_id(url)
  23. req = compat_urllib_request.Request(url)
  24. # it doesn't work if it thinks the browser it's too old
  25. req.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/43.0 (Chrome)')
  26. webpage = self._download_webpage(req, display_id)
  27. theplatform_link = self._html_search_regex(r'src="(http://player.theplatform.com/p/.*?)"', webpage, 'theplatform link')
  28. title = self._html_search_regex(r'<title[^>]*>([^>]+)-\s*\d+\s*|\s*Movieclips.com</title>', webpage, 'title')
  29. description = self._html_search_meta('description', webpage)
  30. return {
  31. '_type': 'url_transparent',
  32. 'url': theplatform_link,
  33. 'title': title,
  34. 'display_id': display_id,
  35. 'description': description,
  36. }