Fix --list-formats (Closes #799)
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 22 Apr 2013 17:51:42 +0000 (19:51 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 22 Apr 2013 17:51:56 +0000 (19:51 +0200)
youtube_dl/FileDownloader.py
youtube_dl/InfoExtractors.py

index 9c0c42f8d44ab5a85df6fd68f272869ca546f940..7139adf6bb6490b31dc3661b0fc220df30b0dad2 100644 (file)
@@ -458,6 +458,8 @@ class FileDownloader(object):
             # 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:
index 14a1d6523f4834ebcd85334d90b256dc6184f916..ff1f07e9b80a35705f4474a59b39df00d578ae72 100755 (executable)
@@ -622,8 +622,7 @@ class YoutubeIE(InfoExtractor):
                 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 @@ class YoutubeIE(InfoExtractor):
                         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: