]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/nowness.py
1 from .brightcove
import (
5 from .common
import InfoExtractor
6 from ..compat
import compat_str
13 class NownessBaseIE(InfoExtractor
):
14 def _extract_url_result(self
, post
):
15 if post
['type'] == 'video':
16 for media
in post
['media']:
17 if media
['type'] == 'video':
18 video_id
= media
['content']
19 source
= media
['source']
20 if source
== 'brightcove':
21 player_code
= self
._download
_webpage
(
22 'http://www.nowness.com/iframe?id=%s' % video_id
, video_id
,
23 note
='Downloading player JavaScript',
24 errnote
='Unable to download player JavaScript')
25 bc_url
= BrightcoveLegacyIE
._extract
_brightcove
_url
(player_code
)
27 return self
.url_result(bc_url
, BrightcoveLegacyIE
.ie_key())
28 bc_url
= BrightcoveNewIE
._extract
_url
(self
, player_code
)
30 return self
.url_result(bc_url
, BrightcoveNewIE
.ie_key())
31 raise ExtractorError('Could not find player definition')
32 elif source
== 'vimeo':
33 return self
.url_result('http://vimeo.com/%s' % video_id
, 'Vimeo')
34 elif source
== 'youtube':
35 return self
.url_result(video_id
, 'Youtube')
36 elif source
== 'cinematique':
37 # yt-dlp currently doesn't support cinematique
38 # return self.url_result('http://cinematique.com/embed/%s' % video_id, 'Cinematique')
41 def _api_request(self
, url
, request_path
):
42 display_id
= self
._match
_id
(url
)
43 request
= sanitized_Request(
44 'http://api.nowness.com/api/' + request_path
% display_id
,
46 'X-Nowness-Language': 'zh-cn' if 'cn.nowness.com' in url
else 'en-us',
48 return display_id
, self
._download
_json
(request
, display_id
)
51 class NownessIE(NownessBaseIE
):
53 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/(?:story|(?:series|category)/[^/]+)/(?P<id>[^/]+?)(?:$|[?#])'
55 'url': 'https://www.nowness.com/story/candor-the-art-of-gesticulation',
56 'md5': '068bc0202558c2e391924cb8cc470676',
58 'id': '2520295746001',
60 'title': 'Candor: The Art of Gesticulation',
61 'description': 'Candor: The Art of Gesticulation',
62 'thumbnail': r
're:^https?://.*\.jpg',
63 'timestamp': 1446745676,
64 'upload_date': '20151105',
65 'uploader_id': '2385340575001',
67 'add_ie': ['BrightcoveNew'],
69 'url': 'https://cn.nowness.com/story/kasper-bjorke-ft-jaakko-eino-kalevi-tnr',
70 'md5': 'e79cf125e387216f86b2e0a5b5c63aa3',
72 'id': '3716354522001',
74 'title': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
75 'description': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
76 'thumbnail': r
're:^https?://.*\.jpg',
77 'timestamp': 1407315371,
78 'upload_date': '20140806',
79 'uploader_id': '2385340575001',
81 'add_ie': ['BrightcoveNew'],
84 'url': 'https://www.nowness.com/series/nowness-picks/jean-luc-godard-supercut',
85 'md5': '9a5a6a8edf806407e411296ab6bc2a49',
89 'title': 'Bleu, Blanc, Rouge - A Godard Supercut',
90 'description': 'md5:f0ea5f1857dffca02dbd37875d742cec',
91 'thumbnail': r
're:^https?://.*\.jpg',
92 'upload_date': '20150607',
93 'uploader': 'Cinema Sem Lei',
94 'uploader_id': 'cinemasemlei',
99 def _real_extract(self
, url
):
100 _
, post
= self
._api
_request
(url
, 'post/getBySlug/%s')
101 return self
._extract
_url
_result
(post
)
104 class NownessPlaylistIE(NownessBaseIE
):
105 IE_NAME
= 'nowness:playlist'
106 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/playlist/(?P<id>\d+)'
108 'url': 'https://www.nowness.com/playlist/3286/i-guess-thats-why-they-call-it-the-blues',
112 'playlist_mincount': 8,
115 def _real_extract(self
, url
):
116 playlist_id
, playlist
= self
._api
_request
(url
, 'post?PlaylistId=%s')
117 entries
= [self
._extract
_url
_result
(item
) for item
in playlist
['items']]
118 return self
.playlist_result(entries
, playlist_id
)
121 class NownessSeriesIE(NownessBaseIE
):
122 IE_NAME
= 'nowness:series'
123 _VALID_URL
= r
'https?://(?:(?:www|cn)\.)?nowness\.com/series/(?P<id>[^/]+?)(?:$|[?#])'
125 'url': 'https://www.nowness.com/series/60-seconds',
128 'title': '60 Seconds',
129 'description': 'One-minute wisdom in a new NOWNESS series',
131 'playlist_mincount': 4,
134 def _real_extract(self
, url
):
135 display_id
, series
= self
._api
_request
(url
, 'series/getBySlug/%s')
136 entries
= [self
._extract
_url
_result
(post
) for post
in series
['posts']]
138 series_description
= None
139 translations
= series
.get('translations', [])
141 series_title
= translations
[0].get('title') or translations
[0]['seoTitle']
142 series_description
= translations
[0].get('seoDescription')
143 return self
.playlist_result(
144 entries
, compat_str(series
['id']), series_title
, series_description
)