Adding proxy to update procedure
authorDavid Ben Zakai <david.benzakai@gmail.com>
Tue, 10 Nov 2015 14:31:31 +0000 (16:31 +0200)
committerDavid Ben Zakai <david.benzakai@gmail.com>
Tue, 10 Nov 2015 14:31:42 +0000 (16:31 +0200)
youtube_dl/YoutubeDL.py
youtube_dl/__init__.py
youtube_dl/update.py

index 1783ce01bf683ab0cfa349a1b040362f88cc1a47..5a0cc3f9a3c565ee4c16b9624ec29b8ad90d2b3c 100755 (executable)
@@ -1994,6 +1994,9 @@ class YoutubeDL(object):
             encoding = preferredencoding()
         return encoding
 
+    def get_opener(self):
+        return self._opener
+
     def _write_thumbnails(self, info_dict, filename):
         if self.params.get('writethumbnail', False):
             thumbnails = info_dict.get('thumbnails')
index 5e2ed4d4b1b48b751b69795f352e72e7efbe5e02..760128546b9cedc31d16bf18b34893f184574565 100644 (file)
@@ -377,7 +377,7 @@ def _real_main(argv=None):
     with YoutubeDL(ydl_opts) as ydl:
         # Update version
         if opts.update_self:
-            update_self(ydl.to_screen, opts.verbose)
+            update_self(ydl.to_screen, opts.verbose, ydl.get_opener())
 
         # Remove cache dir
         if opts.rm_cachedir:
index fc7ac8305d71c8cce077ef3040cd0903ac9f09c5..04bf0939ef905448b23e037fe502b00f0b2eb615 100644 (file)
@@ -13,7 +13,7 @@ from .compat import (
     compat_str,
     compat_urllib_request,
 )
-from .utils import make_HTTPS_handler
+
 from .version import __version__
 
 
@@ -47,7 +47,7 @@ def rsa_verify(message, signature, key):
     return True
 
 
-def update_self(to_screen, verbose):
+def update_self(to_screen, verbose, opener):
     """Update the program file with the latest version from the repository"""
 
     UPDATE_URL = "https://rg3.github.io/youtube-dl/update/"
@@ -59,9 +59,6 @@ def update_self(to_screen, verbose):
         to_screen('It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.')
         return
 
-    https_handler = make_HTTPS_handler({})
-    opener = compat_urllib_request.build_opener(https_handler)
-
     # Check if there is a new version
     try:
         newversion = opener.open(VERSION_URL).read().decode('utf-8').strip()