]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/nzz.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / nzz.py
CommitLineData
33898fb1
RA
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
7from ..utils import (
8 extract_attributes,
9)
10
11
12class NZZIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?nzz\.ch/(?:[^/]+/)*[^/?#]+-ld\.(?P<id>\d+)'
15ed5a27 14 _TESTS = [{
33898fb1
RA
15 'url': 'http://www.nzz.ch/zuerich/gymizyte/gymizyte-schreiben-schueler-heute-noch-diktate-ld.9153',
16 'info_dict': {
17 'id': '9153',
18 },
19 'playlist_mincount': 6,
15ed5a27
AS
20 }, {
21 'url': 'https://www.nzz.ch/video/nzz-standpunkte/cvp-auf-der-suche-nach-dem-mass-der-mitte-ld.1368112',
22 'info_dict': {
23 'id': '1368112',
24 },
25 'playlist_count': 1,
26 }]
33898fb1
RA
27
28 def _real_extract(self, url):
29 page_id = self._match_id(url)
30 webpage = self._download_webpage(url, page_id)
31
32 entries = []
15ed5a27
AS
33 for player_element in re.findall(
34 r'(<[^>]+class="kalturaPlayer[^"]*"[^>]*>)', webpage):
33898fb1
RA
35 player_params = extract_attributes(player_element)
36 if player_params.get('data-type') not in ('kaltura_singleArticle',):
37 self.report_warning('Unsupported player type')
38 continue
39 entry_id = player_params['data-id']
40 entries.append(self.url_result(
41 'kaltura:1750922:' + entry_id, 'Kaltura', entry_id))
42
43 return self.playlist_result(entries, page_id)