mychannels.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from .common import InfoExtractor
  2. class MyChannelsIE(InfoExtractor):
  3. _VALID_URL = r'https?://(?:www\.)?mychannels\.com/.*(?P<id_type>video|production)_id=(?P<id>[0-9]+)'
  4. _TEST = {
  5. 'url': 'https://mychannels.com/missholland/miss-holland?production_id=3416',
  6. 'md5': 'b8993daad4262dd68d89d651c0c52c45',
  7. 'info_dict': {
  8. 'id': 'wUUDZZep6vQD',
  9. 'ext': 'mp4',
  10. 'title': 'Miss Holland joins VOTE LEAVE',
  11. 'description': 'Miss Holland | #13 Not a potato',
  12. 'uploader': 'Miss Holland',
  13. }
  14. }
  15. def _real_extract(self, url):
  16. id_type, url_id = self._match_valid_url(url).groups()
  17. webpage = self._download_webpage(url, url_id)
  18. video_data = self._html_search_regex(r'<div([^>]+data-%s-id="%s"[^>]+)>' % (id_type, url_id), webpage, 'video data')
  19. def extract_data_val(attr, fatal=False):
  20. return self._html_search_regex(r'data-%s\s*=\s*"([^"]+)"' % attr, video_data, attr, fatal=fatal)
  21. minoto_id = extract_data_val('minoto-id') or self._search_regex(r'/id/([a-zA-Z0-9]+)', extract_data_val('video-src', True), 'minoto id')
  22. return {
  23. '_type': 'url_transparent',
  24. 'url': 'minoto:%s' % minoto_id,
  25. 'id': url_id,
  26. 'title': extract_data_val('title', True),
  27. 'description': extract_data_val('description'),
  28. 'thumbnail': extract_data_val('image'),
  29. 'uploader': extract_data_val('channel'),
  30. }