logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

nzz.py (1409B)


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