tva.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. float_or_none,
  4. int_or_none,
  5. smuggle_url,
  6. strip_or_none,
  7. )
  8. class TVAIE(InfoExtractor):
  9. _VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)'
  10. _TESTS = [{
  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. 'skip': 'HTTP Error 404: Not Found',
  25. }, {
  26. 'url': 'https://video.tva.ca/details/_5596811470001',
  27. 'only_matching': True,
  28. }]
  29. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
  30. def _real_extract(self, url):
  31. video_id = self._match_id(url)
  32. return {
  33. '_type': 'url_transparent',
  34. 'id': video_id,
  35. 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
  36. 'ie_key': 'BrightcoveNew',
  37. }
  38. class QubIE(InfoExtractor):
  39. _VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)'
  40. _TESTS = [{
  41. 'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619',
  42. 'md5': '949490fd0e7aee11d0543777611fbd53',
  43. 'info_dict': {
  44. 'id': '6084352463001',
  45. 'ext': 'mp4',
  46. 'title': 'Épisode 01',
  47. 'uploader_id': '5481942443001',
  48. 'upload_date': '20190907',
  49. 'timestamp': 1567899756,
  50. 'description': 'md5:9c0d7fbb90939420c651fd977df90145',
  51. },
  52. }, {
  53. 'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
  54. 'only_matching': True,
  55. }]
  56. # reference_id also works with old account_id(5481942443001)
  57. # BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s'
  58. def _real_extract(self, url):
  59. entity_id = self._match_id(url)
  60. entity = self._download_json(
  61. 'https://www.qub.ca/proxy/pfu/content-delivery-service/v1/entities',
  62. entity_id, query={'id': entity_id})
  63. video_id = entity['videoId']
  64. episode = strip_or_none(entity.get('name'))
  65. return {
  66. '_type': 'url_transparent',
  67. 'id': video_id,
  68. 'title': episode,
  69. # 'url': self.BRIGHTCOVE_URL_TEMPLATE % entity['referenceId'],
  70. 'url': 'https://videos.tva.ca/details/_' + video_id,
  71. 'description': entity.get('longDescription'),
  72. 'duration': float_or_none(entity.get('durationMillis'), 1000),
  73. 'episode': episode,
  74. 'episode_number': int_or_none(entity.get('episodeNumber')),
  75. # 'ie_key': 'BrightcoveNew',
  76. 'ie_key': TVAIE.ie_key(),
  77. }