logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

movieclips.py (1891B)


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