]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/azmedien.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / azmedien.py
CommitLineData
da56fb63 1import json
94629e53
S
2
3from .common import InfoExtractor
4from .kaltura import KalturaIE
94629e53
S
5
6
573531dc 7class AZMedienIE(InfoExtractor):
94629e53
S
8 IE_DESC = 'AZ Medien videos'
9 _VALID_URL = r'''(?x)
10 https?://
504f789a 11 (?:www\.|tv\.)?
da56fb63 12 (?P<host>
94629e53
S
13 telezueri\.ch|
14 telebaern\.tv|
84842aee
B
15 telem1\.ch|
16 tvo-online\.ch
94629e53 17 )/
da56fb63
AS
18 [^/]+/
19 (?P<id>
20 [^/]+-(?P<article_id>\d+)
94629e53 21 )
da56fb63
AS
22 (?:
23 \#video=
24 (?P<kaltura_id>
25 [_0-9a-z]+
26 )
27 )?
94629e53
S
28 '''
29
30 _TESTS = [{
504f789a 31 'url': 'https://tv.telezueri.ch/sonntalk/bundesrats-vakanzen-eu-rahmenabkommen-133214569',
94629e53 32 'info_dict': {
da56fb63 33 'id': '1_anruz3wy',
424505df 34 'ext': 'mp4',
da56fb63 35 'title': 'Bundesrats-Vakanzen / EU-Rahmenabkommen',
da56fb63
AS
36 'uploader_id': 'TVOnline',
37 'upload_date': '20180930',
38 'timestamp': 1538328802,
504f789a
AS
39 'view_count': int,
40 'thumbnail': 'http://cfvod.kaltura.com/p/1719221/sp/171922100/thumbnail/entry_id/1_anruz3wy/version/100031',
add96eb9 41 'duration': 1930,
94629e53
S
42 },
43 'params': {
44 'skip_download': True,
45 },
46 }, {
da56fb63 47 'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
add96eb9 48 'only_matching': True,
94629e53 49 }]
2181983a 50 _API_TEMPL = 'https://www.%s/api/pub/gql/%s/NewsArticleTeaser/a4016f65fe62b81dc6664dd9f4910e4ab40383be'
573531dc
S
51 _PARTNER_ID = '1719221'
52
94629e53 53 def _real_extract(self, url):
5ad28e7f 54 host, display_id, article_id, entry_id = self._match_valid_url(url).groups()
da56fb63
AS
55
56 if not entry_id:
9cf30dc0
RA
57 entry_id = self._download_json(
58 self._API_TEMPL % (host, host.split('.')[0]), display_id, query={
59 'variables': json.dumps({
60 'contextId': 'NewsArticle:' + article_id,
61 }),
62 })['data']['context']['mainAsset']['video']['kaltura']['kalturaId']
da56fb63 63
573531dc 64 return self.url_result(
add96eb9 65 f'kaltura:{self._PARTNER_ID}:{entry_id}',
573531dc 66 ie=KalturaIE.ie_key(), video_id=entry_id)