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.

95 lines
3.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .theplatform import ThePlatformFeedIE
  5. from ..utils import int_or_none
  6. class CorusIE(ThePlatformFeedIE):
  7. _VALID_URL = r'''(?x)
  8. https?://
  9. (?:www\.)?
  10. (?P<domain>
  11. (?:globaltv|etcanada)\.com|
  12. (?:hgtv|foodnetwork|slice|history|showcase)\.ca
  13. )
  14. /(?:video/|(?:[^/]+/)+(?:videos/[a-z0-9-]+-|video\.html\?.*?\bv=))
  15. (?P<id>\d+)
  16. '''
  17. _TESTS = [{
  18. 'url': 'http://www.hgtv.ca/shows/bryan-inc/videos/movie-night-popcorn-with-bryan-870923331648/',
  19. 'md5': '05dcbca777bf1e58c2acbb57168ad3a6',
  20. 'info_dict': {
  21. 'id': '870923331648',
  22. 'ext': 'mp4',
  23. 'title': 'Movie Night Popcorn with Bryan',
  24. 'description': 'Bryan whips up homemade popcorn, the old fashion way for Jojo and Lincoln.',
  25. 'uploader': 'SHWM-NEW',
  26. 'upload_date': '20170206',
  27. 'timestamp': 1486392197,
  28. },
  29. }, {
  30. 'url': 'http://www.foodnetwork.ca/shows/chopped/video/episode/chocolate-obsession/video.html?v=872683587753',
  31. 'only_matching': True,
  32. }, {
  33. 'url': 'http://etcanada.com/video/873675331955/meet-the-survivor-game-changers-castaways-part-2/',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://www.history.ca/the-world-without-canada/video/full-episodes/natural-resources/video.html?v=955054659646#video',
  37. 'only_matching': True,
  38. }, {
  39. 'url': 'http://www.showcase.ca/eyewitness/video/eyewitness++106/video.html?v=955070531919&p=1&s=da#video',
  40. 'only_matching': True,
  41. }]
  42. _TP_FEEDS = {
  43. 'globaltv': {
  44. 'feed_id': 'ChQqrem0lNUp',
  45. 'account_id': 2269680845,
  46. },
  47. 'etcanada': {
  48. 'feed_id': 'ChQqrem0lNUp',
  49. 'account_id': 2269680845,
  50. },
  51. 'hgtv': {
  52. 'feed_id': 'L0BMHXi2no43',
  53. 'account_id': 2414428465,
  54. },
  55. 'foodnetwork': {
  56. 'feed_id': 'ukK8o58zbRmJ',
  57. 'account_id': 2414429569,
  58. },
  59. 'slice': {
  60. 'feed_id': '5tUJLgV2YNJ5',
  61. 'account_id': 2414427935,
  62. },
  63. 'history': {
  64. 'feed_id': 'tQFx_TyyEq4J',
  65. 'account_id': 2369613659,
  66. },
  67. 'showcase': {
  68. 'feed_id': '9H6qyshBZU3E',
  69. 'account_id': 2414426607,
  70. },
  71. }
  72. def _real_extract(self, url):
  73. domain, video_id = re.match(self._VALID_URL, url).groups()
  74. feed_info = self._TP_FEEDS[domain.split('.')[0]]
  75. return self._extract_feed_info('dtjsEC', feed_info['feed_id'], 'byId=' + video_id, video_id, lambda e: {
  76. 'episode_number': int_or_none(e.get('pl1$episode')),
  77. 'season_number': int_or_none(e.get('pl1$season')),
  78. 'series': e.get('pl1$show'),
  79. }, {
  80. 'HLS': {
  81. 'manifest': 'm3u',
  82. },
  83. 'DesktopHLS Default': {
  84. 'manifest': 'm3u',
  85. },
  86. 'MP4 MBR': {
  87. 'manifest': 'm3u',
  88. },
  89. }, feed_info['account_id'])