2 from __future__ import unicode_literals
4 from .common import InfoExtractor
12 class WSJIE(InfoExtractor):
13 _VALID_URL = r'''(?x)https?://
15 video-api\.wsj\.com/api-video/player/iframe\.html\?guid=|
16 (?:www\.)?wsj\.com/video/[^/]+/
18 (?P<id>[a-zA-Z0-9-]+)'''
19 IE_DESC = 'Wall Street Journal'
21 'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
22 'md5': 'e230a5bb249075e40793b655a54a02e4',
24 'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
26 'upload_date': '20150202',
27 'uploader_id': 'jdesai',
29 'categories': list, # a long list
31 'title': 'Bills Coach Rex Ryan Updates His Old Jets Tattoo',
34 'url': 'http://www.wsj.com/video/can-alphabet-build-a-smarter-city/359DDAA8-9AC1-489C-82E6-0429C1E430E0.html',
35 'only_matching': True,
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
42 'http://video-api.wsj.com/api-video/find_all_videos.asp?'
43 'type=guid&count=1&query=%s&fields=type,hls,videoMP4List,'
44 'thumbnailList,author,description,name,duration,videoURL,'
45 'titletag,formattedCreationDate,keywords,editor' % video_id)
46 info = self._download_json(api_url, video_id)['items'][0]
47 title = info.get('name', info.get('titletag'))
51 f4m_url = info.get('videoURL')
53 formats.extend(self._extract_f4m_formats(
54 f4m_url, video_id, f4m_id='hds', fatal=False))
56 m3u8_url = info.get('hls')
58 formats.extend(self._extract_m3u8_formats(
59 info['hls'], video_id, ext='mp4',
60 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
62 for v in info.get('videoMP4List', []):
63 mp4_url = v.get('url')
66 tbr = int_or_none(v.get('bitrate'))
69 'format_id': 'http' + ('-%d' % tbr if tbr else ''),
71 'width': int_or_none(v.get('width')),
72 'height': int_or_none(v.get('height')),
73 'fps': float_or_none(v.get('fps')),
75 self._sort_formats(formats)
80 # Thumbnails are conveniently in the correct format already
81 'thumbnails': info.get('thumbnailList'),
82 'creator': info.get('author'),
83 'uploader_id': info.get('editor'),
84 'duration': int_or_none(info.get('duration')),
85 'upload_date': unified_strdate(info.get(
86 'formattedCreationDate'), day_first=False),
88 'categories': info.get('keywords'),