logo

youtube-dl

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

ctv.py (1772B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class CTVIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?ctv\.ca/(?P<id>(?:show|movie)s/[^/]+/[^/?#&]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.ctv.ca/shows/your-morning/wednesday-december-23-2020-s5e88',
  8. 'info_dict': {
  9. 'id': '2102249',
  10. 'ext': 'flv',
  11. 'title': 'Wednesday, December 23, 2020',
  12. 'thumbnail': r're:^https?://.*\.jpg$',
  13. 'description': 'Your Morning delivers original perspectives and unique insights into the headlines of the day.',
  14. 'timestamp': 1608732000,
  15. 'upload_date': '20201223',
  16. 'series': 'Your Morning',
  17. 'season': '2020-2021',
  18. 'season_number': 5,
  19. 'episode_number': 88,
  20. 'tags': ['Your Morning'],
  21. 'categories': ['Talk Show'],
  22. 'duration': 7467.126,
  23. },
  24. }, {
  25. 'url': 'https://www.ctv.ca/movies/adam-sandlers-eight-crazy-nights/adam-sandlers-eight-crazy-nights',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. display_id = self._match_id(url)
  30. content = self._download_json(
  31. 'https://www.ctv.ca/space-graphql/graphql', display_id, query={
  32. 'query': '''{
  33. resolvedPath(path: "/%s") {
  34. lastSegment {
  35. content {
  36. ... on AxisContent {
  37. axisId
  38. videoPlayerDestCode
  39. }
  40. }
  41. }
  42. }
  43. }''' % display_id,
  44. })['data']['resolvedPath']['lastSegment']['content']
  45. video_id = content['axisId']
  46. return self.url_result(
  47. '9c9media:%s:%s' % (content['videoPlayerDestCode'], video_id),
  48. 'NineCNineMedia', video_id)