]>
Commit | Line | Data |
---|---|---|
37381350 PH |
1 | from __future__ import unicode_literals |
2 | ||
a820dc72 | 3 | import json |
a820dc72 | 4 | |
bb18d787 JMF |
5 | from .common import InfoExtractor |
6 | ||
7 | ||
8 | class AlJazeeraIE(InfoExtractor): | |
a820dc72 | 9 | _VALID_URL = r'https?://(?:www\.)?aljazeera\.com/(?P<type>program/[^/]+|(?:feature|video)s)/\d{4}/\d{1,2}/\d{1,2}/(?P<id>[^/?&#]+)' |
bb18d787 | 10 | |
851a01ae | 11 | _TESTS = [{ |
a820dc72 | 12 | 'url': 'https://www.aljazeera.com/program/episode/2014/9/19/deliverance', |
bb18d787 JMF |
13 | 'info_dict': { |
14 | 'id': '3792260579001', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'The Slum - Episode 1: Deliverance', | |
17 | 'description': 'As a birth attendant advocating for family planning, Remy is on the frontline of Tondo\'s battle with overcrowding.', | |
cb6e477d | 18 | 'uploader_id': '665003303001', |
19 | 'timestamp': 1411116829, | |
20 | 'upload_date': '20140919', | |
bb18d787 | 21 | }, |
cb6e477d | 22 | 'add_ie': ['BrightcoveNew'], |
cf33a47d | 23 | 'skip': 'Not accessible from Travis CI server', |
851a01ae | 24 | }, { |
a820dc72 RA |
25 | 'url': 'https://www.aljazeera.com/videos/2017/5/11/sierra-leone-709-carat-diamond-to-be-auctioned-off', |
26 | 'only_matching': True, | |
27 | }, { | |
28 | 'url': 'https://www.aljazeera.com/features/2017/8/21/transforming-pakistans-buses-into-art', | |
851a01ae LS |
29 | 'only_matching': True, |
30 | }] | |
a820dc72 | 31 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/%s_default/index.html?videoId=%s' |
bb18d787 JMF |
32 | |
33 | def _real_extract(self, url): | |
5ad28e7f | 34 | post_type, name = self._match_valid_url(url).groups() |
a820dc72 RA |
35 | post_type = { |
36 | 'features': 'post', | |
37 | 'program': 'episode', | |
38 | 'videos': 'video', | |
39 | }[post_type.split('/')[0]] | |
40 | video = self._download_json( | |
41 | 'https://www.aljazeera.com/graphql', name, query={ | |
42 | 'operationName': 'SingleArticleQuery', | |
43 | 'variables': json.dumps({ | |
44 | 'name': name, | |
45 | 'postType': post_type, | |
46 | }), | |
47 | }, headers={ | |
48 | 'wp-site': 'aje', | |
49 | })['data']['article']['video'] | |
50 | video_id = video['id'] | |
51 | account_id = video.get('accountId') or '665003303001' | |
52 | player_id = video.get('playerId') or 'BkeSH5BDb' | |
53 | return self.url_result( | |
54 | self.BRIGHTCOVE_URL_TEMPLATE % (account_id, player_id, video_id), | |
55 | 'BrightcoveNew', video_id) |