]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wsj.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class WSJIE(InfoExtractor
):
15 https?://video-api\.wsj\.com/api-video/player/iframe\.html\?.*?\bguid=|
16 https?://(?:www\.)?(?:wsj|barrons)\.com/video/[^/]+/|
19 (?P<id>[a-fA-F0-9-]{36})
21 IE_DESC
= 'Wall Street Journal'
23 'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
24 'md5': 'e230a5bb249075e40793b655a54a02e4',
26 'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
28 'upload_date': '20150202',
29 'uploader_id': 'jdesai',
31 'categories': list, # a long list
33 'title': 'Bills Coach Rex Ryan Updates His Old Jets Tattoo',
36 'url': 'http://www.wsj.com/video/can-alphabet-build-a-smarter-city/359DDAA8-9AC1-489C-82E6-0429C1E430E0.html',
37 'only_matching': True,
39 'url': 'http://www.barrons.com/video/capitalism-deserves-more-respect-from-millennials/F301217E-6F46-43AE-B8D2-B7180D642EE9.html',
40 'only_matching': True,
43 def _real_extract(self
, url
):
44 video_id
= self
._match
_id
(url
)
46 info
= self
._download
_json
(
47 'http://video-api.wsj.com/api-video/find_all_videos.asp', video_id
,
53 'type', 'hls', 'videoMP4List', 'thumbnailList', 'author',
54 'description', 'name', 'duration', 'videoURL', 'titletag',
55 'formattedCreationDate', 'keywords', 'editor')),
57 title
= info
.get('name', info
.get('titletag'))
61 f4m_url
= info
.get('videoURL')
63 formats
.extend(self
._extract
_f
4m
_formats
(
64 f4m_url
, video_id
, f4m_id
='hds', fatal
=False))
66 m3u8_url
= info
.get('hls')
68 formats
.extend(self
._extract
_m
3u8_formats
(
69 info
['hls'], video_id
, ext
='mp4',
70 entry_protocol
='m3u8_native', m3u8_id
='hls', fatal
=False))
72 for v
in info
.get('videoMP4List', []):
73 mp4_url
= v
.get('url')
76 tbr
= int_or_none(v
.get('bitrate'))
79 'format_id': 'http' + ('-%d' % tbr
if tbr
else ''),
81 'width': int_or_none(v
.get('width')),
82 'height': int_or_none(v
.get('height')),
83 'fps': float_or_none(v
.get('fps')),
85 self
._sort
_formats
(formats
)
90 # Thumbnails are conveniently in the correct format already
91 'thumbnails': info
.get('thumbnailList'),
92 'creator': info
.get('author'),
93 'uploader_id': info
.get('editor'),
94 'duration': int_or_none(info
.get('duration')),
95 'upload_date': unified_strdate(info
.get(
96 'formattedCreationDate'), day_first
=False),
98 'categories': info
.get('keywords'),
102 class WSJArticleIE(InfoExtractor
):
103 _VALID_URL
= r
'(?i)https?://(?:www\.)?wsj\.com/articles/(?P<id>[^/?#&]+)'
105 'url': 'https://www.wsj.com/articles/dont-like-china-no-pandas-for-you-1490366939?',
107 'id': '4B13FA62-1D8C-45DB-8EA1-4105CB20B362',
109 'upload_date': '20170221',
110 'uploader_id': 'ralcaraz',
111 'title': 'Bao Bao the Panda Leaves for China',
115 def _real_extract(self
, url
):
116 article_id
= self
._match
_id
(url
)
117 webpage
= self
._download
_webpage
(url
, article_id
)
118 video_id
= self
._search
_regex
(
119 r
'data-src=["\']([a
-fA
-F0
-9-]{36}
)', webpage, 'video
id')
120 return self.url_result('wsj
:%s' % video_id, WSJIE.ie_key(), video_id)