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.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_iso8601,
  7. smuggle_url,
  8. )
  9. class TVAIE(InfoExtractor):
  10. _VALID_URL = r'https?://videos\.tva\.ca/episode/(?P<id>\d+)'
  11. _TEST = {
  12. 'url': 'http://videos.tva.ca/episode/85538',
  13. 'info_dict': {
  14. 'id': '85538',
  15. 'ext': 'mp4',
  16. 'title': 'Épisode du 25 janvier 2017',
  17. 'description': 'md5:e9e7fb5532ab37984d2dc87229cadf98',
  18. 'upload_date': '20170126',
  19. 'timestamp': 1485442329,
  20. },
  21. 'params': {
  22. # m3u8 download
  23. 'skip_download': True,
  24. }
  25. }
  26. def _real_extract(self, url):
  27. video_id = self._match_id(url)
  28. video_data = self._download_json(
  29. "https://d18jmrhziuoi7p.cloudfront.net/isl/api/v1/dataservice/Items('%s')" % video_id,
  30. video_id, query={
  31. '$expand': 'Metadata,CustomId',
  32. '$select': 'Metadata,Id,Title,ShortDescription,LongDescription,CreatedDate,CustomId,AverageUserRating,Categories,ShowName',
  33. '$format': 'json',
  34. })
  35. metadata = video_data.get('Metadata', {})
  36. return {
  37. '_type': 'url_transparent',
  38. 'id': video_id,
  39. 'title': video_data['Title'],
  40. 'url': smuggle_url('ooyala:' + video_data['CustomId'], {'supportedformats': 'm3u8,hds'}),
  41. 'description': video_data.get('LongDescription') or video_data.get('ShortDescription'),
  42. 'series': video_data.get('ShowName'),
  43. 'episode': metadata.get('EpisodeTitle'),
  44. 'episode_number': int_or_none(metadata.get('EpisodeNumber')),
  45. 'categories': video_data.get('Categories'),
  46. 'average_rating': video_data.get('AverageUserRating'),
  47. 'timestamp': parse_iso8601(video_data.get('CreatedDate')),
  48. 'ie_key': 'Ooyala',
  49. }