2017-02-28 16:37:33 +00:00
|
|
|
# coding: utf-8
|
2017-01-21 19:15:20 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-10-02 12:49:01 +00:00
|
|
|
import json
|
2017-01-21 19:15:20 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .kaltura import KalturaIE
|
|
|
|
|
|
|
|
|
2018-11-02 18:32:29 +00:00
|
|
|
class AZMedienIE(InfoExtractor):
|
2017-01-21 19:15:20 +00:00
|
|
|
IE_DESC = 'AZ Medien videos'
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
https?://
|
|
|
|
(?:www\.)?
|
2018-10-02 12:49:01 +00:00
|
|
|
(?P<host>
|
2017-01-21 19:15:20 +00:00
|
|
|
telezueri\.ch|
|
|
|
|
telebaern\.tv|
|
|
|
|
telem1\.ch
|
|
|
|
)/
|
2018-10-02 12:49:01 +00:00
|
|
|
[^/]+/
|
|
|
|
(?P<id>
|
|
|
|
[^/]+-(?P<article_id>\d+)
|
2017-01-21 19:15:20 +00:00
|
|
|
)
|
2018-10-02 12:49:01 +00:00
|
|
|
(?:
|
|
|
|
\#video=
|
|
|
|
(?P<kaltura_id>
|
|
|
|
[_0-9a-z]+
|
|
|
|
)
|
|
|
|
)?
|
2017-01-21 19:15:20 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
_TESTS = [{
|
2018-10-02 12:49:01 +00:00
|
|
|
'url': 'https://www.telezueri.ch/sonntalk/bundesrats-vakanzen-eu-rahmenabkommen-133214569',
|
2017-01-21 19:15:20 +00:00
|
|
|
'info_dict': {
|
2018-10-02 12:49:01 +00:00
|
|
|
'id': '1_anruz3wy',
|
2017-10-20 18:10:56 +00:00
|
|
|
'ext': 'mp4',
|
2018-10-02 12:49:01 +00:00
|
|
|
'title': 'Bundesrats-Vakanzen / EU-Rahmenabkommen',
|
|
|
|
'uploader_id': 'TVOnline',
|
|
|
|
'upload_date': '20180930',
|
|
|
|
'timestamp': 1538328802,
|
2017-01-21 19:15:20 +00:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}, {
|
2018-10-02 12:49:01 +00:00
|
|
|
'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
|
2017-01-21 19:15:20 +00:00
|
|
|
'only_matching': True
|
|
|
|
}]
|
|
|
|
|
2018-11-02 18:32:29 +00:00
|
|
|
_PARTNER_ID = '1719221'
|
|
|
|
|
2017-01-21 19:15:20 +00:00
|
|
|
def _real_extract(self, url):
|
2018-10-02 12:49:01 +00:00
|
|
|
mobj = re.match(self._VALID_URL, url)
|
2018-11-29 17:12:18 +00:00
|
|
|
host = mobj.group('host')
|
2018-11-02 18:32:29 +00:00
|
|
|
video_id = mobj.group('id')
|
2018-10-02 12:49:01 +00:00
|
|
|
entry_id = mobj.group('kaltura_id')
|
|
|
|
|
|
|
|
if not entry_id:
|
2018-11-29 17:12:18 +00:00
|
|
|
api_url = 'https://www.%s/api/pub/gql/%s' % (host, host.split('.')[0])
|
2018-10-02 12:49:01 +00:00
|
|
|
payload = {
|
|
|
|
'query': '''query VideoContext($articleId: ID!) {
|
|
|
|
article: node(id: $articleId) {
|
|
|
|
... on Article {
|
|
|
|
mainAssetRelation {
|
|
|
|
asset {
|
|
|
|
... on VideoAsset {
|
|
|
|
kalturaId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}''',
|
|
|
|
'variables': {'articleId': 'Article:%s' % mobj.group('article_id')},
|
|
|
|
}
|
|
|
|
json_data = self._download_json(
|
|
|
|
api_url, video_id, headers={
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
|
|
|
data=json.dumps(payload).encode())
|
|
|
|
entry_id = json_data['data']['article']['mainAssetRelation']['asset']['kalturaId']
|
|
|
|
|
2018-11-02 18:32:29 +00:00
|
|
|
return self.url_result(
|
|
|
|
'kaltura:%s:%s' % (self._PARTNER_ID, entry_id),
|
|
|
|
ie=KalturaIE.ie_key(), video_id=entry_id)
|