You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

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