From 2c30087e735c558cc7365758c416ec5a7764635b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9stin=20Reed?= Date: Thu, 29 Sep 2016 15:17:48 +0200 Subject: [PATCH] [Morningstar] Modernize --- youtube_dl/extractor/morningstar.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/youtube_dl/extractor/morningstar.py b/youtube_dl/extractor/morningstar.py index 320d27bdd..d191e4c17 100644 --- a/youtube_dl/extractor/morningstar.py +++ b/youtube_dl/extractor/morningstar.py @@ -1,9 +1,11 @@ # coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..utils import ( + ExtractorError, + get_element_by_id, +) class MorningstarIE(InfoExtractor): @@ -16,32 +18,30 @@ class MorningstarIE(InfoExtractor): 'id': '615869', 'ext': 'mp4', 'title': 'Get Ahead of the Curve on 2013 Taxes', - 'description': "Vanguard's Joel Dickson on managing higher tax rates for high-income earners and fund capital-gain distributions in 2013.", + 'description': 'md5:0f71dedfd54bb3dca09e6474e2b624f7', 'thumbnail': r're:^https?://.*m(?:orning)?star\.com/.+thumb\.jpg$' } } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') - + video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - title = self._html_search_regex( - r'

(.*?)

', webpage, 'title') + + title = get_element_by_id('titleLink', webpage) + if not title: + raise ExtractorError('Unable to extract title for %s.' % video_id) + video_url = self._html_search_regex( r'(.*?)', - webpage, 'description', fatal=False) return { 'id': video_id, 'title': title, 'url': video_url, 'thumbnail': thumbnail, - 'description': description, + 'description': get_element_by_id('mstarDeck', webpage), }