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.

118 lines
4.3 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|full-episodes|shows)
  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 ToshIE(MTVServicesInfoExtractor):
  25. IE_DESC = 'Tosh.0'
  26. _VALID_URL = r'^https?://tosh\.cc\.com/video-(?:clips|collections)/[^/]+/(?P<videotitle>[^/?#]+)'
  27. _FEED_URL = 'http://tosh.cc.com/feeds/mrss'
  28. _TESTS = [{
  29. 'url': 'http://tosh.cc.com/video-clips/68g93d/twitter-users-share-summer-plans',
  30. 'info_dict': {
  31. 'description': 'Tosh asked fans to share their summer plans.',
  32. 'title': 'Twitter Users Share Summer Plans',
  33. },
  34. 'playlist': [{
  35. 'md5': 'f269e88114c1805bb6d7653fecea9e06',
  36. 'info_dict': {
  37. 'id': '90498ec2-ed00-11e0-aca6-0026b9414f30',
  38. 'ext': 'mp4',
  39. 'title': 'Tosh.0|June 9, 2077|2|211|Twitter Users Share Summer Plans',
  40. 'description': 'Tosh asked fans to share their summer plans.',
  41. 'thumbnail': 're:^https?://.*\.jpg',
  42. # It's really reported to be published on year 2077
  43. 'upload_date': '20770610',
  44. 'timestamp': 3390510600,
  45. 'subtitles': {
  46. 'en': 'mincount:3',
  47. },
  48. },
  49. }]
  50. }, {
  51. 'url': 'http://tosh.cc.com/video-collections/x2iz7k/just-plain-foul/m5q4fp',
  52. 'only_matching': True,
  53. }]
  54. @classmethod
  55. def _transform_rtmp_url(cls, rtmp_video_url):
  56. new_urls = super(ToshIE, cls)._transform_rtmp_url(rtmp_video_url)
  57. new_urls['rtmp'] = rtmp_video_url.replace('viacomccstrm', 'viacommtvstrm')
  58. return new_urls
  59. class ComedyCentralTVIE(MTVServicesInfoExtractor):
  60. _VALID_URL = r'https?://(?:www\.)?comedycentral\.tv/(?:staffeln|shows)/(?P<id>[^/?#&]+)'
  61. _TESTS = [{
  62. 'url': 'http://www.comedycentral.tv/staffeln/7436-the-mindy-project-staffel-4',
  63. 'info_dict': {
  64. 'id': 'local_playlist-f99b626bdfe13568579a',
  65. 'ext': 'flv',
  66. 'title': 'Episode_the-mindy-project_shows_season-4_episode-3_full-episode_part1',
  67. },
  68. 'params': {
  69. # rtmp download
  70. 'skip_download': True,
  71. },
  72. }, {
  73. 'url': 'http://www.comedycentral.tv/shows/1074-workaholics',
  74. 'only_matching': True,
  75. }, {
  76. 'url': 'http://www.comedycentral.tv/shows/1727-the-mindy-project/bonus',
  77. 'only_matching': True,
  78. }]
  79. def _real_extract(self, url):
  80. video_id = self._match_id(url)
  81. webpage = self._download_webpage(url, video_id)
  82. mrss_url = self._search_regex(
  83. r'data-mrss=(["\'])(?P<url>(?:(?!\1).)+)\1',
  84. webpage, 'mrss url', group='url')
  85. return self._get_videos_info_from_url(mrss_url, video_id)
  86. class ComedyCentralShortnameIE(InfoExtractor):
  87. _VALID_URL = r'^:(?P<id>tds|thedailyshow)$'
  88. _TESTS = [{
  89. 'url': ':tds',
  90. 'only_matching': True,
  91. }, {
  92. 'url': ':thedailyshow',
  93. 'only_matching': True,
  94. }]
  95. def _real_extract(self, url):
  96. video_id = self._match_id(url)
  97. shortcut_map = {
  98. 'tds': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/full-episodes',
  99. 'thedailyshow': 'http://www.cc.com/shows/the-daily-show-with-trevor-noah/full-episodes',
  100. }
  101. return self.url_result(shortcut_map[video_id])