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.

105 lines
3.6 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|bigbrothercanada)\.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. 'url': 'http://www.bigbrothercanada.ca/video/1457812035894/',
  43. 'only_matching': True
  44. }, {
  45. 'url': 'https://www.bigbrothercanada.ca/video/big-brother-canada-704/1457812035894/',
  46. 'only_matching': True
  47. }]
  48. _TP_FEEDS = {
  49. 'globaltv': {
  50. 'feed_id': 'ChQqrem0lNUp',
  51. 'account_id': 2269680845,
  52. },
  53. 'etcanada': {
  54. 'feed_id': 'ChQqrem0lNUp',
  55. 'account_id': 2269680845,
  56. },
  57. 'hgtv': {
  58. 'feed_id': 'L0BMHXi2no43',
  59. 'account_id': 2414428465,
  60. },
  61. 'foodnetwork': {
  62. 'feed_id': 'ukK8o58zbRmJ',
  63. 'account_id': 2414429569,
  64. },
  65. 'slice': {
  66. 'feed_id': '5tUJLgV2YNJ5',
  67. 'account_id': 2414427935,
  68. },
  69. 'history': {
  70. 'feed_id': 'tQFx_TyyEq4J',
  71. 'account_id': 2369613659,
  72. },
  73. 'showcase': {
  74. 'feed_id': '9H6qyshBZU3E',
  75. 'account_id': 2414426607,
  76. },
  77. 'bigbrothercanada': {
  78. 'feed_id': 'ChQqrem0lNUp',
  79. 'account_id': 2269680845,
  80. },
  81. }
  82. def _real_extract(self, url):
  83. domain, video_id = re.match(self._VALID_URL, url).groups()
  84. feed_info = self._TP_FEEDS[domain.split('.')[0]]
  85. return self._extract_feed_info('dtjsEC', feed_info['feed_id'], 'byId=' + video_id, video_id, lambda e: {
  86. 'episode_number': int_or_none(e.get('pl1$episode')),
  87. 'season_number': int_or_none(e.get('pl1$season')),
  88. 'series': e.get('pl1$show'),
  89. }, {
  90. 'HLS': {
  91. 'manifest': 'm3u',
  92. },
  93. 'DesktopHLS Default': {
  94. 'manifest': 'm3u',
  95. },
  96. 'MP4 MBR': {
  97. 'manifest': 'm3u',
  98. },
  99. }, feed_info['account_id'])