]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nowness.py
2 from __future__
import unicode_literals
4 from .brightcove
import (
8 from .common
import InfoExtractor
9 from ..compat
import compat_str
16 class NownessBaseIE(InfoExtractor
):
17 def _extract_url_result(self
, post
):
18 if post
['type'] == 'video':
19 for media
in post
['media']:
20 if media
['type'] == 'video':
21 video_id
= media
['content']
22 source
= media
['source']
23 if source
== 'brightcove':
24 player_code
= self
._download
_webpage
(
25 'http://www.nowness.com/iframe?id=%s' % video_id
, video_id
,
26 note
='Downloading player JavaScript',
27 errnote
='Unable to download player JavaScript')
28 bc_url
= BrightcoveLegacyIE
._extract
_brightcove
_url
(player_code
)
30 return self
.url_result(bc_url
, BrightcoveLegacyIE
.ie_key())
31 bc_url
= BrightcoveNewIE
._extract
_url
(player_code
)
33 return self
.url_result(bc_url
, BrightcoveNewIE
.ie_key())
34 raise ExtractorError('Could not find player definition')
35 elif source
== 'vimeo':
36 return self
.url_result('http://vimeo.com/%s' % video_id
, 'Vimeo')
37 elif source
== 'youtube':
38 return self
.url_result(video_id
, 'Youtube')
39 elif source
== 'cinematique':
40 # youtube-dl currently doesn't support cinematique
41 # return self.url_result('http://cinematique.com/embed/%s' % video_id, 'Cinematique')
44 def _api_request(self
, url
, request_path
):
45 display_id
= self
._match
_id
(url
)
46 request
= sanitized_Request(
47 'http://api.nowness.com/api/' + request_path
% display_id
,
49 'X-Nowness-Language': 'zh-cn' if 'cn.nowness.com' in url
else 'en-us',
51 return display_id
, self
._download
_json
(request
, display_id
)
54 class NownessIE(NownessBaseIE
):
56 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/(?:story|(?:series|category)/[^/]+)/(?P<id>[^/]+?)(?:$|[?#])'
58 'url': 'https://www.nowness.com/story/candor-the-art-of-gesticulation',
59 'md5': '068bc0202558c2e391924cb8cc470676',
61 'id': '2520295746001',
63 'title': 'Candor: The Art of Gesticulation',
64 'description': 'Candor: The Art of Gesticulation',
65 'thumbnail': r
're:^https?://.*\.jpg',
66 'timestamp': 1446745676,
67 'upload_date': '20151105',
68 'uploader_id': '2385340575001',
70 'add_ie': ['BrightcoveNew'],
72 'url': 'https://cn.nowness.com/story/kasper-bjorke-ft-jaakko-eino-kalevi-tnr',
73 'md5': 'e79cf125e387216f86b2e0a5b5c63aa3',
75 'id': '3716354522001',
77 'title': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
78 'description': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
79 'thumbnail': r
're:^https?://.*\.jpg',
80 'timestamp': 1407315371,
81 'upload_date': '20140806',
82 'uploader_id': '2385340575001',
84 'add_ie': ['BrightcoveNew'],
87 'url': 'https://www.nowness.com/series/nowness-picks/jean-luc-godard-supercut',
88 'md5': '9a5a6a8edf806407e411296ab6bc2a49',
92 'title': 'Bleu, Blanc, Rouge - A Godard Supercut',
93 'description': 'md5:f0ea5f1857dffca02dbd37875d742cec',
94 'thumbnail': r
're:^https?://.*\.jpg',
95 'upload_date': '20150607',
96 'uploader': 'Cinema Sem Lei',
97 'uploader_id': 'cinemasemlei',
102 def _real_extract(self
, url
):
103 _
, post
= self
._api
_request
(url
, 'post/getBySlug/%s')
104 return self
._extract
_url
_result
(post
)
107 class NownessPlaylistIE(NownessBaseIE
):
108 IE_NAME
= 'nowness:playlist'
109 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/playlist/(?P<id>\d+)'
111 'url': 'https://www.nowness.com/playlist/3286/i-guess-thats-why-they-call-it-the-blues',
115 'playlist_mincount': 8,
118 def _real_extract(self
, url
):
119 playlist_id
, playlist
= self
._api
_request
(url
, 'post?PlaylistId=%s')
120 entries
= [self
._extract
_url
_result
(item
) for item
in playlist
['items']]
121 return self
.playlist_result(entries
, playlist_id
)
124 class NownessSeriesIE(NownessBaseIE
):
125 IE_NAME
= 'nowness:series'
126 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/series/(?P<id>[^/]+?)(?:$|[?#])'
128 'url': 'https://www.nowness.com/series/60-seconds',
131 'title': '60 Seconds',
132 'description': 'One-minute wisdom in a new NOWNESS series',
134 'playlist_mincount': 4,
137 def _real_extract(self
, url
):
138 display_id
, series
= self
._api
_request
(url
, 'series/getBySlug/%s')
139 entries
= [self
._extract
_url
_result
(post
) for post
in series
['posts']]
141 series_description
= None
142 translations
= series
.get('translations', [])
144 series_title
= translations
[0].get('title') or translations
[0]['seoTitle']
145 series_description
= translations
[0].get('seoDescription')
146 return self
.playlist_result(
147 entries
, compat_str(series
['id']), series_title
, series_description
)