From 561504fffaec8a141a5bdd20ca0a418795d38835 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Thu, 8 Dec 2011 21:39:13 +0100 Subject: [PATCH] Release 2011.12.08 --- LATEST_VERSION | 2 +- README.md | 5 +- youtube-dl | 171 ++++++++++++++++++++++++++++++++++++++--- youtube_dl/__init__.py | 2 +- 4 files changed, 165 insertions(+), 15 deletions(-) diff --git a/LATEST_VERSION b/LATEST_VERSION index 652455915..c39abdfcf 100644 --- a/LATEST_VERSION +++ b/LATEST_VERSION @@ -1 +1 @@ -2011.11.23 +2011.12.08 diff --git a/README.md b/README.md index 8e0b6e794..27a1bfe40 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ which means you can modify it, redistribute it or use it however you like. ### Video Format Options: -f, --format FORMAT video format code --all-formats download all available video formats + --prefer-free-formats prefer free video formats unless a specific one is + requested --max-quality FORMAT highest quality format to download -F, --list-formats list all available formats (currently youtube only) @@ -81,7 +83,8 @@ which means you can modify it, redistribute it or use it however you like. ### Post-processing Options: --extract-audio convert video files to audio-only files (requires ffmpeg and ffprobe) - --audio-format FORMAT "best", "aac", "vorbis" or "mp3"; best by default + --audio-format FORMAT "best", "aac", "vorbis", "mp3", or "m4a"; best by + default --audio-quality QUALITY ffmpeg audio bitrate specification, 128k by default -k, --keep-video keeps the video file on disk after the post- processing; the video is erased by default diff --git a/youtube-dl b/youtube-dl index 042b85267..6a6033491 100755 --- a/youtube-dl +++ b/youtube-dl @@ -18,7 +18,7 @@ __author__ = ( ) __license__ = 'Public Domain' -__version__ = '2011.11.23' +__version__ = '2011.12.08' UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl' @@ -282,6 +282,14 @@ def _simplify_title(title): expr = re.compile(ur'[^\w\d_\-]+', flags=re.UNICODE) return expr.sub(u'_', title).strip(u'_') +def _orderedSet(iterable): + """ Remove all duplicates from the input iterable """ + res = [] + for el in iterable: + if el not in res: + res.append(el) + return res + class DownloadError(Exception): """Download Error exception. @@ -309,6 +317,10 @@ class PostProcessingError(Exception): """ pass +class MaxDownloadsReached(Exception): + """ --max-downloads limit has been reached. """ + pass + class UnavailableVideoError(Exception): """Unavailable Format exception. @@ -722,8 +734,7 @@ class FileDownloader(object): max_downloads = self.params.get('max_downloads') if max_downloads is not None: if self._num_downloads > int(max_downloads): - self.to_screen(u'[download] Maximum number of downloads reached. Skipping ' + info_dict['title']) - return + raise MaxDownloadsReached() filename = self.prepare_filename(info_dict) @@ -1110,6 +1121,7 @@ class YoutubeIE(InfoExtractor): _NETRC_MACHINE = 'youtube' # Listed in order of quality _available_formats = ['38', '37', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13'] + _available_formats_prefer_free = ['38', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13'] _video_extensions = { '13': '3gp', '17': 'mp4', @@ -1359,10 +1371,11 @@ class YoutubeIE(InfoExtractor): url_map = dict((ud['itag'][0], ud['url'][0]) for ud in url_data) format_limit = self._downloader.params.get('format_limit', None) - if format_limit is not None and format_limit in self._available_formats: - format_list = self._available_formats[self._available_formats.index(format_limit):] + available_formats = self._available_formats_prefer_free if self._downloader.params.get('prefer_free_formats', False) else self._available_formats + if format_limit is not None and format_limit in available_formats: + format_list = available_formats[available_formats.index(format_limit):] else: - format_list = self._available_formats + format_list = available_formats existing_formats = [x for x in format_list if x in url_map] if len(existing_formats) == 0: self._downloader.trouble(u'ERROR: no known formats available for video') @@ -3744,6 +3757,124 @@ class MixcloudIE(InfoExtractor): except UnavailableVideoError, err: self._downloader.trouble(u'ERROR: unable to download file') +class StanfordOpenClassroomIE(InfoExtractor): + """Information extractor for Stanford's Open ClassRoom""" + + _VALID_URL = r'^(?:https?://)?openclassroom.stanford.edu(?P/?|(/MainFolder/(?:HomePage|CoursePage|VideoPage)\.php([?]course=(?P[^&]+)(&video=(?P