diff options
author | John Hawkinson <jhawk@mit.edu> | 2017-03-25 19:47:48 -0400 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2017-04-15 20:58:57 +0700 |
commit | 3266d08af29bbd6078aca172741458ddee180ab9 (patch) | |
tree | c5836f1f0f9b0cad72f1f4b22e7f4d37b6806a40 /youtube_dl/extractor/wsj.py | |
parent | 0254f93b08ef5f8af8ea0f1b9f7558892626900b (diff) |
[wsj:article] Add extractor
Diffstat (limited to 'youtube_dl/extractor/wsj.py')
-rw-r--r-- | youtube_dl/extractor/wsj.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/youtube_dl/extractor/wsj.py b/youtube_dl/extractor/wsj.py index deb7483ae..ec38a2ad8 100644 --- a/youtube_dl/extractor/wsj.py +++ b/youtube_dl/extractor/wsj.py @@ -10,10 +10,11 @@ from ..utils import ( class WSJIE(InfoExtractor): - _VALID_URL = r'''(?x)https?:// + _VALID_URL = r'''(?x) (?: - video-api\.wsj\.com/api-video/player/iframe\.html\?guid=| - (?:www\.)?wsj\.com/video/[^/]+/ + https?://video-api\.wsj\.com/api-video/player/iframe\.html\?guid=| + https?://(?:www\.)?wsj\.com/video/[^/]+/| + wsj: ) (?P<id>[a-zA-Z0-9-]+)''' IE_DESC = 'Wall Street Journal' @@ -87,3 +88,24 @@ class WSJIE(InfoExtractor): 'title': title, 'categories': info.get('keywords'), } + + +class WSJArticleIE(InfoExtractor): + _VALID_URL = r'(?i)https?://(?:www\.)?wsj\.com/articles/(?P<id>\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._search_regex(r'data-src=["\']([A-Z0-9\-]+)', + webpage, 'video id') + return self.url_result('wsj:%s' % video_id, WSJIE.ie_key(), video_id) |