From 4408d996fbf2a50323a65adfeb2aa87e5e70fa24 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 27 Nov 2012 22:28:16 +1100 Subject: [PATCH 1/3] Adds format listing/selection support to the Comedy Central extractor. --- youtube_dl/InfoExtractors.py | 42 +++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 3cdce3b25..447695fda 100644 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -2253,6 +2253,25 @@ class ComedyCentralIE(InfoExtractor): _VALID_URL = r'^(:(?Ptds|thedailyshow|cr|colbert|colbertnation|colbertreport))|(https?://)?(www\.)?(?Pthedailyshow|colbertnation)\.com/full-episodes/(?P.*)$' IE_NAME = u'comedycentral' + _available_formats = ['3500', '2200', '1700', '1200', '750', '400'] + + _video_extensions = { + '3500': 'mp4', + '2200': 'mp4', + '1700': 'mp4', + '1200': 'mp4', + '750': 'mp4', + '400': 'mp4', + } + _video_dimensions = { + '3500': '1280x720', + '2200': '960x540', + '1700': '768x432', + '1200': '640x360', + '750': '512x288', + '400': '384x216', + } + def report_extraction(self, episode_id): self._downloader.to_screen(u'[comedycentral] %s: Extracting information' % episode_id) @@ -2265,6 +2284,14 @@ def report_index_download(self, episode_id): def report_player_url(self, episode_id): self._downloader.to_screen(u'[comedycentral] %s: Determining player URL' % episode_id) + + def _print_formats(self, formats): + print('Available formats:') + for x in formats: + print('%s\t:\t%s\t[%s]' %(x, self._video_extensions.get(x, 'mp4'), self._video_dimensions.get(x, '???'))) + + + def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) if mobj is None: @@ -2359,7 +2386,20 @@ def _real_extract(self, url): continue # For now, just pick the highest bitrate - format,video_url = turls[-1] + + print turls + + if self._downloader.params.get('listformats', None): + self._print_formats([i[0] for i in turls]) + return + + format,video_url = turls[-1] + req_format = self._downloader.params.get('format', None) + + for f,v in turls: + if f == req_format: + format, video_url = f, v + break # Patch to download from alternative CDN, which does not # break on current RTMPDump builds From d8dddb7c0221959ff1ca4f833c535253e66fe747 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 27 Nov 2012 22:30:07 +1100 Subject: [PATCH 2/3] Removes extranous debugging info :) --- youtube_dl/InfoExtractors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 447695fda..0829bbb1a 100644 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -2384,18 +2384,18 @@ def _real_extract(self, url): if len(turls) == 0: self._downloader.trouble(u'\nERROR: unable to download ' + mediaId + ': No videos found') continue - - # For now, just pick the highest bitrate - print turls - if self._downloader.params.get('listformats', None): self._print_formats([i[0] for i in turls]) return + # For now, just pick the highest bitrate format,video_url = turls[-1] + + # Get the format arg from the arg stream req_format = self._downloader.params.get('format', None) + # Select format if we can find one for f,v in turls: if f == req_format: format, video_url = f, v From feb22fe5fe55f51a72af6ef4207dba95c6da1fda Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 27 Nov 2012 22:32:24 +1100 Subject: [PATCH 3/3] Fixed indentation error --- youtube_dl/InfoExtractors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 0829bbb1a..64383fea4 100644 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -2390,7 +2390,7 @@ def _real_extract(self, url): return # For now, just pick the highest bitrate - format,video_url = turls[-1] + format,video_url = turls[-1] # Get the format arg from the arg stream req_format = self._downloader.params.get('format', None)