From d7386f6276b7b01ff4254136524d29c8f243721e Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 22 Nov 2013 23:05:56 +0100 Subject: [PATCH] [update] Check if version from repository is newer before updating Closes #1704 --- youtube_dl/update.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/youtube_dl/update.py b/youtube_dl/update.py index e5f441707..be7800e8b 100644 --- a/youtube_dl/update.py +++ b/youtube_dl/update.py @@ -41,6 +41,7 @@ def b(x): if signature != sha256(message).digest(): return False return True + def update_self(to_screen, verbose): """Update the program file with the latest version from the repository""" @@ -82,6 +83,13 @@ def update_self(to_screen, verbose): return version_id = versions_info['latest'] + + def version_tuple(version_str): + return tuple(map(int, version_str.split('.'))) + if version_tuple(__version__) >= version_tuple(version_str): + to_screen(u'youtube-dl is up to date (%s)' % __version__) + return + to_screen(u'Updating to version ' + version_id + '...') version = versions_info['versions'][version_id]