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.

50 lines
1.8 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|news)\.)morningstar\.com/[cC]over/video[cC]enter\.aspx\?id=(?P<id>[0-9]+)'
  8. _TESTS = [{
  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. 'url': 'http://news.morningstar.com/cover/videocenter.aspx?id=825556',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. webpage = self._download_webpage(url, video_id)
  26. title = self._html_search_regex(
  27. r'<h1 id="titleLink">(.*?)</h1>', webpage, 'title')
  28. video_url = self._html_search_regex(
  29. r'<input type="hidden" id="hidVideoUrl" value="([^"]+)"',
  30. webpage, 'video URL')
  31. thumbnail = self._html_search_regex(
  32. r'<input type="hidden" id="hidSnapshot" value="([^"]+)"',
  33. webpage, 'thumbnail', fatal=False)
  34. description = self._html_search_regex(
  35. r'<div id="mstarDeck".*?>(.*?)</div>',
  36. webpage, 'description', fatal=False)
  37. return {
  38. 'id': video_id,
  39. 'title': title,
  40. 'url': video_url,
  41. 'thumbnail': thumbnail,
  42. 'description': description,
  43. }