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