1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-13 18:15:34 +08:00

Fix for CNBC videos

This commit is contained in:
JCGoran 2017-09-20 22:00:42 +00:00 committed by GitHub
parent 082893d66d
commit c081ea0d82

View File

@ -1,8 +1,6 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
smuggle_url, smuggle_url,
@ -11,7 +9,7 @@ from ..utils import (
class CNBCIE(InfoExtractor): class CNBCIE(InfoExtractor):
_VALID_URL = r'https?://www\.cnbc\.com/video/[0-9]{4}/[0-9]{2}/[0-9]{2}/(?P<title>.+)\.html' _VALID_URL = r'https?://www\.cnbc\.com/video/[0-9]{4}/[0-9]{2}/[0-9]{2}/(?P<id>.+)\.html'
_TEST = { _TEST = {
'url': 'https://www.cnbc.com/video/2016/03/30/fighting-zombies-is-big-business.html', 'url': 'https://www.cnbc.com/video/2016/03/30/fighting-zombies-is-big-business.html',
'info_dict': { 'info_dict': {
@ -30,23 +28,22 @@ class CNBCIE(InfoExtractor):
} }
def _real_extract(self, url): def _real_extract(self, url):
mob = re.search(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mob.group('title')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
mobj = re.search( video_url = self._search_regex(
r'mpscall\s*=\s*(?P<json_data>[^)]+),\s*mpsopts', r'mpscall\s*=\s*(?P<json_data>[^)]+),\s*mpsopts',
webpage) webpage, 'json_data')
if mobj is None: if video_url is None:
raise ExtractorError('Unable to extract video urls') raise ExtractorError('Unable to extract video urls')
urls_info = self._parse_json( urls_info = self._parse_json(
mobj.group('json_data'), video_id, transform_source = js_to_json) video_url, video_id, transform_source = js_to_json)
return { return {
'_type': 'url_transparent', '_type': 'url_transparent',
'ie_key': 'ThePlatform', 'ie_key': 'ThePlatform',
'url': smuggle_url( 'url': smuggle_url(
'http://link.theplatform.com/s/gZWlPC/media/guid/2408950221/%s?mbr=true&manifest=m3u' % urls_info.get('content_id'), 'http://link.theplatform.com/s/gZWlPC/media/guid/2408950221/%s?mbr=true&manifest=m3u' % urls_info['content_id'],
{'force_smil_url': True}), {'force_smil_url': True}),
'id': urls_info.get('content_id'), 'id': urls_info['content_id'],
} }