2021-01-16 17:12:05 +00:00
|
|
|
import json
|
|
|
|
|
2014-12-16 14:48:01 +00:00
|
|
|
from .common import InfoExtractor
|
2021-11-27 08:12:56 +00:00
|
|
|
from ..utils import (
|
|
|
|
try_get,
|
|
|
|
)
|
2014-12-16 14:48:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AlJazeeraIE(InfoExtractor):
|
2021-11-27 08:12:56 +00:00
|
|
|
_VALID_URL = r'https?://(?P<base>\w+\.aljazeera\.\w+)/(?P<type>programs?/[^/]+|(?:feature|video|new)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-11-27 08:12:56 +00:00
|
|
|
'url': 'https://balkans.aljazeera.net/videos/2021/11/6/pojedini-domovi-u-sarajevu-jos-pod-vodom-mjestanima-se-dostavlja-hrana',
|
2014-12-16 14:48:01 +00:00
|
|
|
'info_dict': {
|
2021-11-27 08:12:56 +00:00
|
|
|
'id': '6280641530001',
|
2014-12-16 14:48:01 +00:00
|
|
|
'ext': 'mp4',
|
2021-11-27 08:12:56 +00:00
|
|
|
'title': 'Pojedini domovi u Sarajevu još pod vodom, mještanima se dostavlja hrana',
|
|
|
|
'timestamp': 1636219149,
|
|
|
|
'description': 'U sarajevskim naseljima Rajlovac i Reljevo stambeni objekti, ali i industrijska postrojenja i dalje su pod vodom.',
|
|
|
|
'upload_date': '20211106',
|
|
|
|
}
|
2021-01-16 17:12:05 +00:00
|
|
|
}, {
|
2021-11-27 08:12:56 +00:00
|
|
|
'url': 'https://balkans.aljazeera.net/videos/2021/11/6/djokovic-usao-u-finale-mastersa-u-parizu',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '6280654936001',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Đoković ušao u finale Mastersa u Parizu',
|
|
|
|
'timestamp': 1636221686,
|
|
|
|
'description': 'Novak Đoković je u polufinalu Mastersa u Parizu nakon preokreta pobijedio Poljaka Huberta Hurkacza.',
|
|
|
|
'upload_date': '20211106',
|
|
|
|
},
|
2017-05-13 17:57:02 +00:00
|
|
|
}]
|
2021-11-27 08:12:56 +00:00
|
|
|
BRIGHTCOVE_URL_RE = r'https?://players.brightcove.net/(?P<account>\d+)/(?P<player_id>[a-zA-Z0-9]+)_(?P<embed>[^/]+)/index.html\?videoId=(?P<id>\d+)'
|
2014-12-16 14:48:01 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-11-27 08:12:56 +00:00
|
|
|
base, post_type, id = self._match_valid_url(url).groups()
|
|
|
|
wp = {
|
|
|
|
'balkans.aljazeera.net': 'ajb',
|
|
|
|
'chinese.aljazeera.net': 'chinese',
|
|
|
|
'mubasher.aljazeera.net': 'ajm',
|
|
|
|
}.get(base) or 'aje'
|
2021-01-16 17:12:05 +00:00
|
|
|
post_type = {
|
|
|
|
'features': 'post',
|
|
|
|
'program': 'episode',
|
2021-11-27 08:12:56 +00:00
|
|
|
'programs': 'episode',
|
2021-01-16 17:12:05 +00:00
|
|
|
'videos': 'video',
|
2021-11-27 08:12:56 +00:00
|
|
|
'news': 'news',
|
2021-01-16 17:12:05 +00:00
|
|
|
}[post_type.split('/')[0]]
|
|
|
|
video = self._download_json(
|
2021-11-27 08:12:56 +00:00
|
|
|
f'https://{base}/graphql', id, query={
|
|
|
|
'wp-site': wp,
|
2021-08-23 09:54:15 +00:00
|
|
|
'operationName': 'ArchipelagoSingleArticleQuery',
|
2021-01-16 17:12:05 +00:00
|
|
|
'variables': json.dumps({
|
2021-11-27 08:12:56 +00:00
|
|
|
'name': id,
|
2021-01-16 17:12:05 +00:00
|
|
|
'postType': post_type,
|
|
|
|
}),
|
|
|
|
}, headers={
|
2021-11-27 08:12:56 +00:00
|
|
|
'wp-site': wp,
|
|
|
|
})
|
|
|
|
video = try_get(video, lambda x: x['data']['article']['video']) or {}
|
|
|
|
video_id = video.get('id')
|
|
|
|
account = video.get('accountId') or '911432371001'
|
|
|
|
player_id = video.get('playerId') or 'csvTfAlKW'
|
|
|
|
embed = 'default'
|
|
|
|
|
|
|
|
if video_id is None:
|
|
|
|
webpage = self._download_webpage(url, id)
|
|
|
|
|
|
|
|
account, player_id, embed, video_id = self._search_regex(self.BRIGHTCOVE_URL_RE, webpage, 'video id',
|
|
|
|
group=(1, 2, 3, 4), default=(None, None, None, None))
|
|
|
|
|
|
|
|
if video_id is None:
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'url': url,
|
|
|
|
'ie_key': 'Generic'
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'url': f'https://players.brightcove.net/{account}/{player_id}_{embed}/index.html?videoId={video_id}',
|
|
|
|
'ie_key': 'BrightcoveNew'
|
|
|
|
}
|