]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wsj.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class WSJIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://video-api\.wsj\.com/api-video/player/iframe\.html\?guid=(?P<id>[a-zA-Z0-9-]+)'
13 IE_DESC
= 'Wall Street Journal'
15 'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
16 'md5': '9747d7a6ebc2f4df64b981e1dde9efa9',
18 'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
20 'upload_date': '20150202',
21 'uploader_id': 'bbright',
23 'categories': list, # a long list
25 'title': 'Bills Coach Rex Ryan Updates His Old Jets Tattoo',
29 def _real_extract(self
, url
):
30 video_id
= self
._match
_id
(url
)
32 bitrates
= [128, 174, 264, 320, 464, 664, 1264]
34 'http://video-api.wsj.com/api-video/find_all_videos.asp?'
35 'type=guid&count=1&query=%s&'
36 'fields=hls,adZone,thumbnailList,guid,state,secondsUntilStartTime,'
37 'author,description,name,linkURL,videoStillURL,duration,videoURL,'
38 'adCategory,catastrophic,linkShortURL,doctypeID,youtubeID,'
39 'titletag,rssURL,wsj-section,wsj-subsection,allthingsd-section,'
40 'allthingsd-subsection,sm-section,sm-subsection,provider,'
41 'formattedCreationDate,keywords,keywordsOmniture,column,editor,'
42 'emailURL,emailPartnerID,showName,omnitureProgramName,'
43 'omnitureVideoFormat,linkRelativeURL,touchCastID,'
44 'omniturePublishDate,%s') % (
45 video_id
, ','.join('video%dkMP4Url' % br
for br
in bitrates
))
46 info
= self
._download
_json
(api_url
, video_id
)['items'][0]
48 # Thumbnails are conveniently in the correct format already
49 thumbnails
= info
.get('thumbnailList')
50 creator
= info
.get('author')
51 uploader_id
= info
.get('editor')
52 categories
= info
.get('keywords')
53 duration
= int_or_none(info
.get('duration'))
54 upload_date
= unified_strdate(
55 info
.get('formattedCreationDate'), day_first
=False)
56 title
= info
.get('name', info
.get('titletag'))
60 'format_note': 'f4m (meta URL)',
61 'url': info
['videoURL'],
64 formats
.extend(self
._extract
_m
3u8_formats
(
65 info
['hls'], video_id
, ext
='mp4',
66 preference
=0, entry_protocol
='m3u8_native'))
68 field
= 'video%dkMP4Url' % br
71 'format_id': 'mp4-%d' % br
,
76 self
._sort
_formats
(formats
)
81 'thumbnails': thumbnails
,
83 'uploader_id': uploader_id
,
85 'upload_date': upload_date
,
88 'categories': categories
,