Credit @JohnyMoSwag for WorldstarhiphopIE (#730)
[youtube-dl] / youtube_dl / __init__.py
index 823ca63a48cd72a888f8908e7de33ff2774b23a2..1fc2fbcb48efc51ff5830d9ad9e3a9dd025419ab 100644 (file)
@@ -25,10 +25,14 @@ __authors__  = (
     'Jeff Crouse',
     'Osama Khalid',
     'Michael Walter',
+    'M. Yasoob Ullah Khalid',
+    'Julien Fraichard',
+    'Johny Mo Swag',
     )
 
 __license__ = 'Public Domain'
 
+import codecs
 import getpass
 import optparse
 import os
@@ -147,6 +151,7 @@ def parseOpts(overrideArguments=None):
             action='store_true', dest='list_extractors',
             help='List all supported extractors and the URLs they would handle', default=False)
     general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL')
+    general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.')
     general.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP)
 
     selection.add_option('--playlist-start',
@@ -334,6 +339,11 @@ def parseOpts(overrideArguments=None):
     return parser, opts, args
 
 def _real_main(argv=None):
+    # Compatibility fixes for Windows
+    if sys.platform == 'win32':
+        # https://github.com/rg3/youtube-dl/issues/820
+        codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None)
+
     parser, opts, args = parseOpts(argv)
 
     # Open appropriate CookieJar
@@ -388,7 +398,7 @@ def _real_main(argv=None):
         if 'http' in proxies and 'https' not in proxies:
             proxies['https'] = proxies['http']
     proxy_handler = compat_urllib_request.ProxyHandler(proxies)
-    https_handler = compat_urllib_request.HTTPSHandler()
+    https_handler = make_HTTPS_handler(opts)
     opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, YoutubeDLHandler())
     compat_urllib_request.install_opener(opener)
     socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)