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