verbose flag, and output proxies if it is set
[youtube-dl.git] / youtube_dl / __init__.py
index fb45adc..4c9c237 100755 (executable)
@@ -18,7 +18,7 @@ __authors__  = (
        )
 
 __license__ = 'Public Domain'
-__version__ = '2012.01.08'
+__version__ = '2012.01.08b'
 
 UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl'
 
@@ -305,7 +305,14 @@ def _encodeFilename(s):
        """
 
        assert type(s) == type(u'')
-       return s.encode(sys.getfilesystemencoding(), 'ignore')
+
+       if sys.platform == 'win32' and sys.getwindowsversion().major >= 5:
+               # Pass u'' directly to use Unicode APIs on Windows 2000 and up
+               # (Detecting Windows NT 4 is tricky because 'major >= 4' would
+               # match Windows 9x series as well. Besides, NT 4 is obsolete.)
+               return s
+       else:
+               return s.encode(sys.getfilesystemencoding(), 'ignore')
 
 class DownloadError(Exception):
        """Download Error exception.
@@ -4344,6 +4351,8 @@ def parseOpts():
        verbosity.add_option('--console-title',
                        action='store_true', dest='consoletitle',
                        help='display progress in console titlebar', default=False)
+       verbosity.add_option('-v', '--verbose',
+                       action='store_true', dest='verbose', help='print various debugging information', default=False)
 
 
        filesystem.add_option('-t', '--title',
@@ -4480,10 +4489,14 @@ def _real_main():
 
        # General configuration
        cookie_processor = urllib2.HTTPCookieProcessor(jar)
-       opener = urllib2.build_opener(urllib2.ProxyHandler(), cookie_processor, YoutubeDLHandler())
+       proxy_handler = urllib2.ProxyHandler()
+       opener = urllib2.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
        urllib2.install_opener(opener)
        socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
 
+       if opts.verbose:
+               print(u'[debug] Proxy map: ' + str(proxy_handler.proxies))
+
        extractors = gen_extractors()
 
        if opts.list_extractors: