azmedien.py 2.4 KB

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