From c681a03918a8f67f25e3ae7cc4140b76d6a73578 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 22 Apr 2013 19:51:42 +0200 Subject: [PATCH] Fix --list-formats (Closes #799) --- youtube_dl/FileDownloader.py | 2 ++ youtube_dl/InfoExtractors.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 9c0c42f8d..7139adf6b 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -458,6 +458,8 @@ def extract_info(self, url, download = True, ie_name = None): # Extract information from URL and process it try: ie_results = ie.extract(url) + if ie_results is None: # Finished already (backwards compatibility; listformats and friends should be moved here) + break results = [] for ie_result in ie_results: if not 'extractor' in ie_result: diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 14a1d6523..ff1f07e9b 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -622,8 +622,7 @@ def _real_extract(self, url): format_list = available_formats existing_formats = [x for x in format_list if x in url_map] if len(existing_formats) == 0: - self._downloader.report_error(u'no known formats available for video') - return + raise ExtractorError(u'no known formats available for video') if self._downloader.params.get('listformats', None): self._print_formats(existing_formats) return @@ -643,11 +642,9 @@ def _real_extract(self, url): video_url_list = [(rf, url_map[rf])] break if video_url_list is None: - self._downloader.report_error(u'requested format not available') - return + raise ExtractorError(u'requested format not available') else: - self._downloader.report_error(u'no conn or url_encoded_fmt_stream_map information found in video info') - return + raise ExtractorError(u'no conn or url_encoded_fmt_stream_map information found in video info') results = [] for format_param, video_real_url in video_url_list: