0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-14 01:05:06 +00:00
yt-dlp/yt_dlp/extractor/azmedien.py

67 lines
2.4 KiB
Python
Raw Normal View History

import json
2017-01-21 19:15:20 +00:00
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\.|tv\.)?
(?P<host>
2017-01-21 19:15:20 +00:00
telezueri\.ch|
telebaern\.tv|
telem1\.ch|
tvo-online\.ch
2017-01-21 19:15:20 +00:00
)/
[^/]+/
(?P<id>
[^/]+-(?P<article_id>\d+)
2017-01-21 19:15:20 +00:00
)
(?:
\#video=
(?P<kaltura_id>
[_0-9a-z]+
)
)?
2017-01-21 19:15:20 +00:00
'''
_TESTS = [{
'url': 'https://tv.telezueri.ch/sonntalk/bundesrats-vakanzen-eu-rahmenabkommen-133214569',
2017-01-21 19:15:20 +00:00
'info_dict': {
'id': '1_anruz3wy',
2017-10-20 18:10:56 +00:00
'ext': 'mp4',
'title': 'Bundesrats-Vakanzen / EU-Rahmenabkommen',
'uploader_id': 'TVOnline',
'upload_date': '20180930',
'timestamp': 1538328802,
'view_count': int,
'thumbnail': 'http://cfvod.kaltura.com/p/1719221/sp/171922100/thumbnail/entry_id/1_anruz3wy/version/100031',
'duration': 1930,
2017-01-21 19:15:20 +00:00
},
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
'only_matching': True,
2017-01-21 19:15:20 +00:00
}]
_API_TEMPL = 'https://www.%s/api/pub/gql/%s/NewsArticleTeaser/a4016f65fe62b81dc6664dd9f4910e4ab40383be'
2018-11-02 18:32:29 +00:00
_PARTNER_ID = '1719221'
2017-01-21 19:15:20 +00:00
def _real_extract(self, url):
host, display_id, article_id, entry_id = self._match_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-02 18:32:29 +00:00
return self.url_result(
f'kaltura:{self._PARTNER_ID}:{entry_id}',
2018-11-02 18:32:29 +00:00
ie=KalturaIE.ie_key(), video_id=entry_id)