1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-22 23:42:54 +08:00
youtube-dl/youtube_dl/extractor/azmedien.py

67 lines
2.2 KiB
Python
Raw Normal View History

# coding: utf-8
2017-01-22 03:15:20 +08:00
from __future__ import unicode_literals
import json
2017-01-22 03:15:20 +08:00
import re
from .common import InfoExtractor
from .kaltura import KalturaIE
2018-11-03 02:32:29 +08:00
class AZMedienIE(InfoExtractor):
2017-01-22 03:15:20 +08:00
IE_DESC = 'AZ Medien videos'
_VALID_URL = r'''(?x)
https?://
(?:www\.)?
(?P<host>
2017-01-22 03:15:20 +08:00
telezueri\.ch|
telebaern\.tv|
telem1\.ch
)/
[^/]+/
(?P<id>
[^/]+-(?P<article_id>\d+)
2017-01-22 03:15:20 +08:00
)
(?:
\#video=
(?P<kaltura_id>
[_0-9a-z]+
)
)?
2017-01-22 03:15:20 +08:00
'''
_TESTS = [{
'url': 'https://www.telezueri.ch/sonntalk/bundesrats-vakanzen-eu-rahmenabkommen-133214569',
2017-01-22 03:15:20 +08:00
'info_dict': {
'id': '1_anruz3wy',
2017-10-21 02:10:56 +08:00
'ext': 'mp4',
'title': 'Bundesrats-Vakanzen / EU-Rahmenabkommen',
'uploader_id': 'TVOnline',
'upload_date': '20180930',
'timestamp': 1538328802,
2017-01-22 03:15:20 +08:00
},
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
2017-01-22 03:15:20 +08:00
'only_matching': True
}]
_API_TEMPL = 'https://www.%s/api/pub/gql/%s/NewsArticleTeaser/cb9f2f81ed22e9b47f4ca64ea3cc5a5d13e88d1d'
2018-11-03 02:32:29 +08:00
_PARTNER_ID = '1719221'
2017-01-22 03:15:20 +08:00
def _real_extract(self, url):
host, display_id, article_id, entry_id = re.match(self._VALID_URL, url).groups()
if not entry_id:
entry_id = self._download_json(
self._API_TEMPL % (host, host.split('.')[0]), display_id, query={
'variables': json.dumps({
'contextId': 'NewsArticle:' + article_id,
}),
})['data']['context']['mainAsset']['video']['kaltura']['kalturaId']
2018-11-03 02:32:29 +08:00
return self.url_result(
'kaltura:%s:%s' % (self._PARTNER_ID, entry_id),
ie=KalturaIE.ie_key(), video_id=entry_id)