2014-12-16 23:08:04 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2021-01-16 17:12:05 +00:00
|
|
|
import json
|
|
|
|
|
2014-12-16 14:48:01 +00:00
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class AlJazeeraIE(InfoExtractor):
|
2021-01-16 17:12:05 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?aljazeera\.com/(?P<type>program/[^/]+|(?:feature|video)s)/\d{4}/\d{1,2}/\d{1,2}/(?P<id>[^/?&#]+)'
|
2014-12-16 14:48:01 +00:00
|
|
|
|
2017-05-13 17:57:02 +00:00
|
|
|
_TESTS = [{
|
2021-01-16 17:12:05 +00:00
|
|
|
'url': 'https://www.aljazeera.com/program/episode/2014/9/19/deliverance',
|
2014-12-16 14:48:01 +00:00
|
|
|
'info_dict': {
|
|
|
|
'id': '3792260579001',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'The Slum - Episode 1: Deliverance',
|
|
|
|
'description': 'As a birth attendant advocating for family planning, Remy is on the frontline of Tondo\'s battle with overcrowding.',
|
2016-03-15 18:38:10 +00:00
|
|
|
'uploader_id': '665003303001',
|
|
|
|
'timestamp': 1411116829,
|
|
|
|
'upload_date': '20140919',
|
2014-12-16 14:48:01 +00:00
|
|
|
},
|
2016-03-15 18:38:10 +00:00
|
|
|
'add_ie': ['BrightcoveNew'],
|
2015-09-07 07:22:38 +00:00
|
|
|
'skip': 'Not accessible from Travis CI server',
|
2017-05-13 17:57:02 +00:00
|
|
|
}, {
|
2021-01-16 17:12:05 +00:00
|
|
|
'url': 'https://www.aljazeera.com/videos/2017/5/11/sierra-leone-709-carat-diamond-to-be-auctioned-off',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.aljazeera.com/features/2017/8/21/transforming-pakistans-buses-into-art',
|
2017-05-13 17:57:02 +00:00
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2021-01-16 17:12:05 +00:00
|
|
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/%s_default/index.html?videoId=%s'
|
2014-12-16 14:48:01 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 01:41:24 +00:00
|
|
|
post_type, name = self._match_valid_url(url).groups()
|
2021-01-16 17:12:05 +00:00
|
|
|
post_type = {
|
|
|
|
'features': 'post',
|
|
|
|
'program': 'episode',
|
|
|
|
'videos': 'video',
|
|
|
|
}[post_type.split('/')[0]]
|
|
|
|
video = self._download_json(
|
|
|
|
'https://www.aljazeera.com/graphql', name, query={
|
2021-08-23 09:54:15 +00:00
|
|
|
'operationName': 'ArchipelagoSingleArticleQuery',
|
2021-01-16 17:12:05 +00:00
|
|
|
'variables': json.dumps({
|
|
|
|
'name': name,
|
|
|
|
'postType': post_type,
|
|
|
|
}),
|
|
|
|
}, headers={
|
|
|
|
'wp-site': 'aje',
|
|
|
|
})['data']['article']['video']
|
|
|
|
video_id = video['id']
|
|
|
|
account_id = video.get('accountId') or '665003303001'
|
|
|
|
player_id = video.get('playerId') or 'BkeSH5BDb'
|
|
|
|
return self.url_result(
|
|
|
|
self.BRIGHTCOVE_URL_TEMPLATE % (account_id, player_id, video_id),
|
|
|
|
'BrightcoveNew', video_id)
|