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.

47 lines
1.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class MorningstarIE(InfoExtractor):
  6. IE_DESC = 'morningstar.com'
  7. _VALID_URL = r'https?://(?:www\.)?morningstar\.com/[cC]over/video[cC]enter\.aspx\?id=(?P<id>[0-9]+)'
  8. _TEST = {
  9. 'url': 'http://www.morningstar.com/cover/videocenter.aspx?id=615869',
  10. 'md5': '6c0acface7a787aadc8391e4bbf7b0f5',
  11. 'info_dict': {
  12. 'id': '615869',
  13. 'ext': 'mp4',
  14. 'title': 'Get Ahead of the Curve on 2013 Taxes',
  15. 'description': "Vanguard's Joel Dickson on managing higher tax rates for high-income earners and fund capital-gain distributions in 2013.",
  16. 'thumbnail': r're:^https?://.*m(?:orning)?star\.com/.+thumb\.jpg$'
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. webpage = self._download_webpage(url, video_id)
  23. title = self._html_search_regex(
  24. r'<h1 id="titleLink">(.*?)</h1>', webpage, 'title')
  25. video_url = self._html_search_regex(
  26. r'<input type="hidden" id="hidVideoUrl" value="([^"]+)"',
  27. webpage, 'video URL')
  28. thumbnail = self._html_search_regex(
  29. r'<input type="hidden" id="hidSnapshot" value="([^"]+)"',
  30. webpage, 'thumbnail', fatal=False)
  31. description = self._html_search_regex(
  32. r'<div id="mstarDeck".*?>(.*?)</div>',
  33. webpage, 'description', fatal=False)
  34. return {
  35. 'id': video_id,
  36. 'title': title,
  37. 'url': video_url,
  38. 'thumbnail': thumbnail,
  39. 'description': description,
  40. }