[YoutubeDL] Simplify API of YoutubeDL
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 28 Oct 2014 11:54:29 +0000 (12:54 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 28 Oct 2014 11:54:29 +0000 (12:54 +0100)
Calling add_default_extractors twice should be harmless since the first set of extractors will match.

youtube_dl/YoutubeDL.py
youtube_dl/__init__.py

index 28dcc0195b5d243a9f1e7672043c164bf6f20fea..fd775b9fd18a9ccf5cb116c60cd93f34c62a209c 100755 (executable)
@@ -189,7 +189,7 @@ class YoutubeDL(object):
     _num_downloads = None
     _screen_file = None
 
-    def __init__(self, params=None):
+    def __init__(self, params=None, auto_init=True):
         """Create a FileDownloader object with the given options."""
         if params is None:
             params = {}
@@ -246,6 +246,10 @@ class YoutubeDL(object):
 
         self._setup_opener()
 
+        if auto_init:
+            self.print_debug_header()
+            self.add_default_info_extractors()
+
     def add_info_extractor(self, ie):
         """Add an InfoExtractor object to the end of the list."""
         self._ies.append(ie)
index 7dc971884cc5cad523510bd03b477b2450c2efb3..3c968082c3e69fbd38bf229905cd3469cef88ab3 100644 (file)
@@ -293,9 +293,6 @@ def _real_main(argv=None):
     }
 
     with YoutubeDL(ydl_opts) as ydl:
-        ydl.print_debug_header()
-        ydl.add_default_info_extractors()
-
         # PostProcessors
         # Add the metadata pp first, the other pps will copy it
         if opts.addmetadata: