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.

55 lines
1.8 KiB

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