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