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.

54 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. float_or_none,
  6. smuggle_url,
  7. )
  8. class TVAIE(InfoExtractor):
  9. _VALID_URL = r'https?://videos\.tva\.ca/details/_(?P<id>\d+)'
  10. _TEST = {
  11. 'url': 'https://videos.tva.ca/details/_5596811470001',
  12. 'info_dict': {
  13. 'id': '5596811470001',
  14. 'ext': 'mp4',
  15. 'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !',
  16. 'uploader_id': '5481942443001',
  17. 'upload_date': '20171003',
  18. 'timestamp': 1507064617,
  19. },
  20. 'params': {
  21. # m3u8 download
  22. 'skip_download': True,
  23. }
  24. }
  25. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
  26. def _real_extract(self, url):
  27. video_id = self._match_id(url)
  28. video_data = self._download_json(
  29. 'https://videos.tva.ca/proxy/item/_' + video_id, video_id, headers={
  30. 'Accept': 'application/json',
  31. }, query={
  32. 'appId': '5955fc5f23eec60006c951f1',
  33. })
  34. def get_attribute(key):
  35. for attribute in video_data.get('attributes', []):
  36. if attribute.get('key') == key:
  37. return attribute.get('value')
  38. return None
  39. return {
  40. '_type': 'url_transparent',
  41. 'id': video_id,
  42. 'title': get_attribute('title'),
  43. 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
  44. 'description': get_attribute('description'),
  45. 'thumbnail': get_attribute('image-background') or get_attribute('image-landscape'),
  46. 'duration': float_or_none(get_attribute('video-duration'), 1000),
  47. 'ie_key': 'BrightcoveNew',
  48. }