diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6a7028a4d..84bbec6c4 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1210,7 +1210,10 @@ from .wrzuta import ( WrzutaIE, WrzutaPlaylistIE, ) -from .wsj import WSJIE +from .wsj import ( + WSJIE, + WSJArticleIE, +) from .xbef import XBefIE from .xboxclips import XboxClipsIE from .xfileshare import XFileShareIE diff --git a/youtube_dl/extractor/wsj.py b/youtube_dl/extractor/wsj.py index deb7483ae..cd03bdc6d 100644 --- a/youtube_dl/extractor/wsj.py +++ b/youtube_dl/extractor/wsj.py @@ -37,7 +37,9 @@ class WSJIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) + return self._extract_video(video_id) + def _extract_video(self, video_id): api_url = ( 'http://video-api.wsj.com/api-video/find_all_videos.asp?' 'type=guid&count=1&query=%s&fields=type,hls,videoMP4List,' @@ -87,3 +89,24 @@ class WSJIE(InfoExtractor): 'title': title, 'categories': info.get('keywords'), } + + +class WSJArticleIE(WSJIE): + _VALID_URL = r'(?i)https?://(?:www\.)?wsj\.com/articles/(?P\w[^/]+)' + _TESTS = [{ + 'url': 'https://www.wsj.com/articles/dont-like-china-no-pandas-for-you-1490366939?', + 'info_dict': { + 'id': '4B13FA62-1D8C-45DB-8EA1-4105CB20B362', + 'ext': 'mp4', + 'upload_date': '20170221', + 'uploader_id': 'ralcaraz', + 'title': 'Bao Bao the Panda Leaves for China', + } + }] + + def _real_extract(self, url): + article_id = self._match_id(url) + webpage = self._download_webpage(url, article_id) + video_id = self._html_search_regex(r'data-src=["\']([A-Z0-9\-]+)', + webpage, 'video id') + return self._extract_video(video_id)