3 from .common import InfoExtractor
4 from .mtv import MTVIE, _media_xml_tag
14 class ComedyCentralIE(MTVIE):
15 _VALID_URL = r'http://www.comedycentral.com/(video-clips|episodes|cc-studios)/(?P<title>.*)'
16 _FEED_URL = u'http://comedycentral.com/feeds/mrss/'
19 u'url': u'http://www.comedycentral.com/video-clips/kllhuv/stand-up-greg-fitzsimmons--uncensored---too-good-of-a-mother',
20 u'md5': u'4167875aae411f903b751a21f357f1ee',
22 u'id': u'cef0cbb3-e776-4bc9-b62e-8016deccb354',
24 u'title': u'Uncensored - Greg Fitzsimmons - Too Good of a Mother',
25 u'description': u'After a certain point, breastfeeding becomes c**kblocking.',
28 # Overwrite MTVIE properties we don't want
31 def _get_thumbnail_url(self, uri, itemdoc):
32 search_path = '%s/%s' % (_media_xml_tag('group'), _media_xml_tag('thumbnail'))
33 return itemdoc.find(search_path).attrib['url']
35 def _real_extract(self, url):
36 mobj = re.match(self._VALID_URL, url)
37 title = mobj.group('title')
38 webpage = self._download_webpage(url, title)
39 mgid = self._search_regex(r'data-mgid="(?P<mgid>mgid:.*?)"',
41 return self._get_videos_info(mgid)
44 class ComedyCentralShowsIE(InfoExtractor):
45 IE_DESC = u'The Daily Show / Colbert Report'
46 # urls can be abbreviations like :thedailyshow or :colbert
47 # urls for episodes like:
48 # or urls for clips like: http://www.thedailyshow.com/watch/mon-december-10-2012/any-given-gun-day
49 # or: http://www.colbertnation.com/the-colbert-report-videos/421667/november-29-2012/moon-shattering-news
50 # or: http://www.colbertnation.com/the-colbert-report-collections/422008/festival-of-lights/79524
51 _VALID_URL = r"""^(:(?P<shortname>tds|thedailyshow|cr|colbert|colbertnation|colbertreport)
53 (?P<showname>thedailyshow|colbertnation)\.com/
54 (full-episodes/(?P<episode>.*)|
56 (the-colbert-report-(videos|collections)/(?P<clipID>[0-9]+)/[^/]*/(?P<cntitle>.*?))
57 |(watch/(?P<date>[^/]*)/(?P<tdstitle>.*)))|
59 extended-interviews/(?P<interID>[0-9]+)/playlist_tds_extended_(?P<interview_title>.*?)/.*?)))
62 u'url': u'http://www.thedailyshow.com/watch/thu-december-13-2012/kristen-stewart',
63 u'file': u'422212.mp4',
64 u'md5': u'4e2f5cb088a83cd8cdb7756132f9739d',
66 u"upload_date": u"20121214",
67 u"description": u"Kristen Stewart",
68 u"uploader": u"thedailyshow",
69 u"title": u"thedailyshow-kristen-stewart part 1"
73 _available_formats = ['3500', '2200', '1700', '1200', '750', '400']
93 def suitable(cls, url):
94 """Receives a URL and returns True if suitable for this IE."""
95 return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
98 def _transform_rtmp_url(rtmp_video_url):
99 m = re.match(r'^rtmpe?://.*?/(?P<finalid>gsp.comedystor/.*)$', rtmp_video_url)
101 raise ExtractorError(u'Cannot transform RTMP url')
102 base = 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=1+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxK=18639+_pxE=mp4/44620/mtvnorigin/'
103 return base + m.group('finalid')
105 def _real_extract(self, url):
106 mobj = re.match(self._VALID_URL, url, re.VERBOSE)
108 raise ExtractorError(u'Invalid URL: %s' % url)
110 if mobj.group('shortname'):
111 if mobj.group('shortname') in ('tds', 'thedailyshow'):
112 url = u'http://www.thedailyshow.com/full-episodes/'
114 url = u'http://www.colbertnation.com/full-episodes/'
115 mobj = re.match(self._VALID_URL, url, re.VERBOSE)
116 assert mobj is not None
118 if mobj.group('clip'):
119 if mobj.group('showname') == 'thedailyshow':
120 epTitle = mobj.group('tdstitle')
122 epTitle = mobj.group('cntitle')
124 elif mobj.group('interview'):
125 epTitle = mobj.group('interview_title')
128 dlNewest = not mobj.group('episode')
130 epTitle = mobj.group('showname')
132 epTitle = mobj.group('episode')
134 self.report_extraction(epTitle)
135 webpage,htmlHandle = self._download_webpage_handle(url, epTitle)
137 url = htmlHandle.geturl()
138 mobj = re.match(self._VALID_URL, url, re.VERBOSE)
140 raise ExtractorError(u'Invalid redirected URL: ' + url)
141 if mobj.group('episode') == '':
142 raise ExtractorError(u'Redirected URL is still not specific: ' + url)
143 epTitle = mobj.group('episode')
145 mMovieParams = re.findall('(?:<param name="movie" value="|var url = ")(http://media.mtvnservices.com/([^"]*(?:episode|video).*?:.*?))"', webpage)
147 if len(mMovieParams) == 0:
148 # The Colbert Report embeds the information in a without
149 # a URL prefix; so extract the alternate reference
150 # and then add the URL prefix manually.
152 altMovieParams = re.findall('data-mgid="([^"]*(?:episode|video).*?:.*?)"', webpage)
153 if len(altMovieParams) == 0:
154 raise ExtractorError(u'unable to find Flash URL in webpage ' + url)
156 mMovieParams = [("http://media.mtvnservices.com/" + altMovieParams[0], altMovieParams[0])]
158 uri = mMovieParams[0][1]
159 indexUrl = 'http://shadow.comedycentral.com/feeds/video_player/mrss/?' + compat_urllib_parse.urlencode({'uri': uri})
160 idoc = self._download_xml(indexUrl, epTitle,
161 u'Downloading show index',
162 u'unable to download episode index')
166 itemEls = idoc.findall('.//item')
167 for partNum,itemEl in enumerate(itemEls):
168 mediaId = itemEl.findall('./guid')[0].text
169 shortMediaId = mediaId.split(':')[-1]
170 showId = mediaId.split(':')[-2].replace('.com', '')
171 officialTitle = itemEl.findall('./title')[0].text
172 officialDate = unified_strdate(itemEl.findall('./pubDate')[0].text)
174 configUrl = ('http://www.comedycentral.com/global/feeds/entertainment/media/mediaGenEntertainment.jhtml?' +
175 compat_urllib_parse.urlencode({'uri': mediaId}))
176 cdoc = self._download_xml(configUrl, epTitle,
177 u'Downloading configuration for %s' % shortMediaId)
180 for rendition in cdoc.findall('.//rendition'):
181 finfo = (rendition.attrib['bitrate'], rendition.findall('./src')[0].text)
185 self._downloader.report_error(u'unable to download ' + mediaId + ': No videos found')
189 for format, rtmp_video_url in turls:
190 w, h = self._video_dimensions.get(format, (None, None))
192 'url': self._transform_rtmp_url(rtmp_video_url),
193 'ext': self._video_extensions.get(format, 'mp4'),
199 effTitle = showId + u'-' + epTitle + u' part ' + compat_str(partNum+1)
204 'upload_date': officialDate,
207 'description': compat_str(officialTitle),
210 # TODO: Remove when #980 has been merged
211 info.update(info['formats'][-1])