logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tva.py (3158B)


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