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.

40 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class MakersChannelIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?makerschannel\.com/.*(?P<id_type>video|production)_id=(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://makerschannel.com/en/zoomin/community-highlights?video_id=849',
  9. 'md5': '624a512c6969236b5967bf9286345ad1',
  10. 'info_dict': {
  11. 'id': '849',
  12. 'ext': 'mp4',
  13. 'title': 'Landing a bus on a plane is an epic win',
  14. 'uploader': 'ZoomIn',
  15. 'description': 'md5:cd9cca2ea7b69b78be81d07020c97139',
  16. }
  17. }
  18. def _real_extract(self, url):
  19. id_type, url_id = re.match(self._VALID_URL, url).groups()
  20. webpage = self._download_webpage(url, url_id)
  21. video_data = self._html_search_regex(r'<div([^>]+data-%s-id="%s"[^>]+)>' % (id_type, url_id), webpage, 'video data')
  22. def extract_data_val(attr, fatal=False):
  23. return self._html_search_regex(r'data-%s\s*=\s*"([^"]+)"' % attr, video_data, attr, fatal=fatal)
  24. minoto_id = self._search_regex(r'/id/([a-zA-Z0-9]+)', extract_data_val('video-src', True), 'minoto id')
  25. return {
  26. '_type': 'url_transparent',
  27. 'url': 'minoto:%s' % minoto_id,
  28. 'id': extract_data_val('video-id', True),
  29. 'title': extract_data_val('title', True),
  30. 'description': extract_data_val('description'),
  31. 'thumbnail': extract_data_val('image'),
  32. 'uploader': extract_data_val('channel'),
  33. }