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.

152 lines
5.7 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. from .mtv import MTVServicesInfoExtractor
  3. from .common import InfoExtractor
  4. class ComedyCentralIE(MTVServicesInfoExtractor):
  5. _VALID_URL = r'''(?x)https?://(?:www\.)?cc\.com/
  6. (video-clips|episodes|cc-studios|video-collections|shows(?=/[^/]+/(?!full-episodes)))
  7. /(?P<title>.*)'''
  8. _FEED_URL = 'http://comedycentral.com/feeds/mrss/'
  9. _TESTS = [{
  10. 'url': 'http://www.cc.com/video-clips/kllhuv/stand-up-greg-fitzsimmons--uncensored---too-good-of-a-mother',
  11. 'md5': 'c4f48e9eda1b16dd10add0744344b6d8',
  12. 'info_dict': {
  13. 'id': 'cef0cbb3-e776-4bc9-b62e-8016deccb354',
  14. 'ext': 'mp4',
  15. 'title': 'CC:Stand-Up|August 18, 2013|1|0101|Uncensored - Too Good of a Mother',
  16. 'description': 'After a certain point, breastfeeding becomes c**kblocking.',
  17. 'timestamp': 1376798400,
  18. 'upload_date': '20130818',
  19. },
  20. }, {
  21. 'url': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/interviews/6yx39d/exclusive-rand-paul-extended-interview',
  22. 'only_matching': True,
  23. }]
  24. class ComedyCentralFullEpisodesIE(MTVServicesInfoExtractor):
  25. _VALID_URL = r'''(?x)https?://(?:www\.)?cc\.com/
  26. (?:full-episodes|shows(?=/[^/]+/full-episodes))
  27. /(?P<id>[^?]+)'''
  28. _FEED_URL = 'http://comedycentral.com/feeds/mrss/'
  29. _TESTS = [{
  30. 'url': 'http://www.cc.com/full-episodes/pv391a/the-daily-show-with-trevor-noah-november-28--2016---ryan-speedo-green-season-22-ep-22028',
  31. 'info_dict': {
  32. 'description': 'Donald Trump is accused of exploiting his president-elect status for personal gain, Cuban leader Fidel Castro dies, and Ryan Speedo Green discusses "Sing for Your Life."',
  33. 'title': 'November 28, 2016 - Ryan Speedo Green',
  34. },
  35. 'playlist_count': 4,
  36. }, {
  37. 'url': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/full-episodes',
  38. 'only_matching': True,
  39. }]
  40. def _real_extract(self, url):
  41. playlist_id = self._match_id(url)
  42. webpage = self._download_webpage(url, playlist_id)
  43. feed_json = self._search_regex(r'var triforceManifestFeed\s*=\s*(\{.+?\});\n', webpage, 'triforce feeed')
  44. feed = self._parse_json(feed_json, playlist_id)
  45. zones = feed['manifest']['zones']
  46. video_zone = zones['t2_lc_promo1']
  47. feed = self._download_json(video_zone['feed'], playlist_id)
  48. mgid = feed['result']['data']['id']
  49. videos_info = self._get_videos_info(mgid)
  50. return videos_info
  51. class ToshIE(MTVServicesInfoExtractor):
  52. IE_DESC = 'Tosh.0'
  53. _VALID_URL = r'^https?://tosh\.cc\.com/video-(?:clips|collections)/[^/]+/(?P<videotitle>[^/?#]+)'
  54. _FEED_URL = 'http://tosh.cc.com/feeds/mrss'
  55. _TESTS = [{
  56. 'url': 'http://tosh.cc.com/video-clips/68g93d/twitter-users-share-summer-plans',
  57. 'info_dict': {
  58. 'description': 'Tosh asked fans to share their summer plans.',
  59. 'title': 'Twitter Users Share Summer Plans',
  60. },
  61. 'playlist': [{
  62. 'md5': 'f269e88114c1805bb6d7653fecea9e06',
  63. 'info_dict': {
  64. 'id': '90498ec2-ed00-11e0-aca6-0026b9414f30',
  65. 'ext': 'mp4',
  66. 'title': 'Tosh.0|June 9, 2077|2|211|Twitter Users Share Summer Plans',
  67. 'description': 'Tosh asked fans to share their summer plans.',
  68. 'thumbnail': 're:^https?://.*\.jpg',
  69. # It's really reported to be published on year 2077
  70. 'upload_date': '20770610',
  71. 'timestamp': 3390510600,
  72. 'subtitles': {
  73. 'en': 'mincount:3',
  74. },
  75. },
  76. }]
  77. }, {
  78. 'url': 'http://tosh.cc.com/video-collections/x2iz7k/just-plain-foul/m5q4fp',
  79. 'only_matching': True,
  80. }]
  81. @classmethod
  82. def _transform_rtmp_url(cls, rtmp_video_url):
  83. new_urls = super(ToshIE, cls)._transform_rtmp_url(rtmp_video_url)
  84. new_urls['rtmp'] = rtmp_video_url.replace('viacomccstrm', 'viacommtvstrm')
  85. return new_urls
  86. class ComedyCentralTVIE(MTVServicesInfoExtractor):
  87. _VALID_URL = r'https?://(?:www\.)?comedycentral\.tv/(?:staffeln|shows)/(?P<id>[^/?#&]+)'
  88. _TESTS = [{
  89. 'url': 'http://www.comedycentral.tv/staffeln/7436-the-mindy-project-staffel-4',
  90. 'info_dict': {
  91. 'id': 'local_playlist-f99b626bdfe13568579a',
  92. 'ext': 'flv',
  93. 'title': 'Episode_the-mindy-project_shows_season-4_episode-3_full-episode_part1',
  94. },
  95. 'params': {
  96. # rtmp download
  97. 'skip_download': True,
  98. },
  99. }, {
  100. 'url': 'http://www.comedycentral.tv/shows/1074-workaholics',
  101. 'only_matching': True,
  102. }, {
  103. 'url': 'http://www.comedycentral.tv/shows/1727-the-mindy-project/bonus',
  104. 'only_matching': True,
  105. }]
  106. def _real_extract(self, url):
  107. video_id = self._match_id(url)
  108. webpage = self._download_webpage(url, video_id)
  109. mrss_url = self._search_regex(
  110. r'data-mrss=(["\'])(?P<url>(?:(?!\1).)+)\1',
  111. webpage, 'mrss url', group='url')
  112. return self._get_videos_info_from_url(mrss_url, video_id)
  113. class ComedyCentralShortnameIE(InfoExtractor):
  114. _VALID_URL = r'^:(?P<id>tds|thedailyshow)$'
  115. _TESTS = [{
  116. 'url': ':tds',
  117. 'only_matching': True,
  118. }, {
  119. 'url': ':thedailyshow',
  120. 'only_matching': True,
  121. }]
  122. def _real_extract(self, url):
  123. video_id = self._match_id(url)
  124. shortcut_map = {
  125. 'tds': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/full-episodes',
  126. 'thedailyshow': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/full-episodes',
  127. }
  128. return self.url_result(shortcut_map[video_id])