movieclips.py 1.6 KB

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