ctv.py 1.7 KB

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