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