]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/morningstar.py
[extractor] Common function `_match_valid_url`
[yt-dlp.git] / yt_dlp / extractor / morningstar.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4
5 from .common import InfoExtractor
6
7
8 class MorningstarIE(InfoExtractor):
9 IE_DESC = 'morningstar.com'
10 _VALID_URL = r'https?://(?:(?:www|news)\.)morningstar\.com/[cC]over/video[cC]enter\.aspx\?id=(?P<id>[0-9]+)'
11 _TESTS = [{
12 'url': 'http://www.morningstar.com/cover/videocenter.aspx?id=615869',
13 'md5': '6c0acface7a787aadc8391e4bbf7b0f5',
14 'info_dict': {
15 'id': '615869',
16 'ext': 'mp4',
17 'title': 'Get Ahead of the Curve on 2013 Taxes',
18 'description': "Vanguard's Joel Dickson on managing higher tax rates for high-income earners and fund capital-gain distributions in 2013.",
19 'thumbnail': r're:^https?://.*m(?:orning)?star\.com/.+thumb\.jpg$'
20 }
21 }, {
22 'url': 'http://news.morningstar.com/cover/videocenter.aspx?id=825556',
23 'only_matching': True,
24 }]
25
26 def _real_extract(self, url):
27 mobj = self._match_valid_url(url)
28 video_id = mobj.group('id')
29
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
43 return {
44 'id': video_id,
45 'title': title,
46 'url': video_url,
47 'thumbnail': thumbnail,
48 'description': description,
49 }