From d3d3e2e3aac13c3c6fbae0fcfeaa41ce5ee9144b Mon Sep 17 00:00:00 2001 From: David Ben Zakai Date: Tue, 10 Nov 2015 16:31:31 +0200 Subject: [PATCH 1/3] Adding proxy to update procedure --- youtube_dl/YoutubeDL.py | 3 +++ youtube_dl/__init__.py | 2 +- youtube_dl/update.py | 7 ++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 1783ce01b..5a0cc3f9a 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -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') diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 5e2ed4d4b..760128546 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -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: diff --git a/youtube_dl/update.py b/youtube_dl/update.py index fc7ac8305..04bf0939e 100644 --- a/youtube_dl/update.py +++ b/youtube_dl/update.py @@ -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() From 90bb5667bf32574caa7c01f66b3ca8ad2ab77e81 Mon Sep 17 00:00:00 2001 From: David Ben Zakai Date: Tue, 10 Nov 2015 17:15:23 +0200 Subject: [PATCH 2/3] Using internal opener --- youtube_dl/YoutubeDL.py | 3 --- youtube_dl/__init__.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 5a0cc3f9a..1783ce01b 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1994,9 +1994,6 @@ 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') diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 760128546..9f131f5db 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -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, ydl.get_opener()) + update_self(ydl.to_screen, opts.verbose, ydl._opener) # Remove cache dir if opts.rm_cachedir: From 828b2a5cd971ae04469aeb7b11dfeaab7962c4d9 Mon Sep 17 00:00:00 2001 From: David Ben Zakai Date: Sun, 15 Nov 2015 09:40:32 +0200 Subject: [PATCH 3/3] Removing an unnecessary import --- youtube_dl/update.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/youtube_dl/update.py b/youtube_dl/update.py index 04bf0939e..074eb64a7 100644 --- a/youtube_dl/update.py +++ b/youtube_dl/update.py @@ -9,10 +9,7 @@ import subprocess import sys from zipimport import zipimporter -from .compat import ( - compat_str, - compat_urllib_request, -) +from .compat import compat_str from .version import __version__