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.

49 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. int_or_none,
  7. smuggle_url,
  8. try_get,
  9. )
  10. class TeleQuebecIE(InfoExtractor):
  11. _VALID_URL = r'https?://zonevideo\.telequebec\.tv/media/(?P<id>\d+)'
  12. _TESTS = [{
  13. 'url': 'http://zonevideo.telequebec.tv/media/20984/le-couronnement-de-new-york/couronnement-de-new-york',
  14. 'md5': 'fe95a0957e5707b1b01f5013e725c90f',
  15. 'info_dict': {
  16. 'id': '20984',
  17. 'ext': 'mp4',
  18. 'title': 'Le couronnement de New York',
  19. 'description': 'md5:f5b3d27a689ec6c1486132b2d687d432',
  20. 'upload_date': '20170201',
  21. 'timestamp': 1485972222,
  22. }
  23. }, {
  24. # no description
  25. 'url': 'http://zonevideo.telequebec.tv/media/30261',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. media_id = self._match_id(url)
  30. media_data = self._download_json(
  31. 'https://mnmedias.api.telequebec.tv/api/v2/media/' + media_id,
  32. media_id)['media']
  33. return {
  34. '_type': 'url_transparent',
  35. 'id': media_id,
  36. 'url': smuggle_url(
  37. 'limelight:media:' + media_data['streamInfo']['sourceId'],
  38. {'geo_countries': ['CA']}),
  39. 'title': media_data['title'],
  40. 'description': try_get(
  41. media_data, lambda x: x['descriptions'][0]['text'], compat_str),
  42. 'duration': int_or_none(
  43. media_data.get('durationInMilliseconds'), 1000),
  44. 'ie_key': 'LimelightMedia',
  45. }