movieclips.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. smuggle_url,
  4. float_or_none,
  5. parse_iso8601,
  6. update_url_query,
  7. )
  8. class MovieClipsIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?movieclips\.com/videos/.+-(?P<id>\d+)(?:\?|$)'
  10. _TEST = {
  11. 'url': 'http://www.movieclips.com/videos/warcraft-trailer-1-561180739597',
  12. 'md5': '42b5a0352d4933a7bd54f2104f481244',
  13. 'info_dict': {
  14. 'id': 'pKIGmG83AqD9',
  15. 'ext': 'mp4',
  16. 'title': 'Warcraft Trailer 1',
  17. 'description': 'Watch Trailer 1 from Warcraft (2016). Legendary’s WARCRAFT is a 3D epic adventure of world-colliding conflict based.',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. 'timestamp': 1446843055,
  20. 'upload_date': '20151106',
  21. 'uploader': 'Movieclips',
  22. },
  23. 'add_ie': ['ThePlatform'],
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. video = next(v for v in self._parse_json(self._search_regex(
  29. r'var\s+__REACT_ENGINE__\s*=\s*({.+});',
  30. webpage, 'react engine'), video_id)['playlist']['videos'] if v['id'] == video_id)
  31. return {
  32. '_type': 'url_transparent',
  33. 'ie_key': 'ThePlatform',
  34. 'url': smuggle_url(update_url_query(
  35. video['contentUrl'], {'mbr': 'true'}), {'force_smil_url': True}),
  36. 'title': self._og_search_title(webpage),
  37. 'description': self._html_search_meta('description', webpage),
  38. 'duration': float_or_none(video.get('duration')),
  39. 'timestamp': parse_iso8601(video.get('dateCreated')),
  40. 'thumbnail': video.get('defaultImage'),
  41. 'uploader': video.get('provider'),
  42. }