aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2011-08-28 23:38:40 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2011-08-28 23:38:40 +0200
commitd207e7cf88947df1ded016959f921f0e3e172159 (patch)
treea4eedc0cbd747c6b50608445424b349bf98029c9
parent36cf7bccde454a0b11a0ab492ed58cd34ee9a6f2 (diff)
Update update mechanism (Closes #4)
-rw-r--r--LATEST_VERSION1
-rwxr-xr-xyoutube-dl23
2 files changed, 14 insertions, 10 deletions
diff --git a/LATEST_VERSION b/LATEST_VERSION
deleted file mode 100644
index 8a3bb049a..000000000
--- a/LATEST_VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2011.08.04
diff --git a/youtube-dl b/youtube-dl
index 5ffd53bd3..534c7ac87 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -15,6 +15,8 @@ __author__ = (
__license__ = 'Public Domain'
__version__ = '2011.08.28-phihag'
+UPDATE_URL = 'https://raw.github.com/phihag/youtube-dl/master/youtube-dl'
+
import cookielib
import datetime
import gzip
@@ -3071,24 +3073,27 @@ def updateSelf(downloader, filename):
if not os.access(filename, os.W_OK):
sys.exit('ERROR: no write permissions on %s' % filename)
- downloader.to_screen('Updating to latest stable version...')
+ downloader.to_screen('Updating to latest version...')
try:
- latest_url = 'http://github.com/rg3/youtube-dl/raw/master/LATEST_VERSION'
- latest_version = urllib.urlopen(latest_url).read().strip()
- prog_url = 'http://github.com/rg3/youtube-dl/raw/%s/youtube-dl' % latest_version
- newcontent = urllib.urlopen(prog_url).read()
+ try:
+ urlh = urllib.urlopen(UPDATE_URL)
+ newcontent = urlh.read()
+ finally:
+ urlh.close()
except (IOError, OSError), err:
sys.exit('ERROR: unable to download latest version')
try:
- stream = open(filename, 'wb')
- stream.write(newcontent)
- stream.close()
+ outf = open(filename, 'wb')
+ try:
+ outf.write(newcontent)
+ finally:
+ outf.close()
except (IOError, OSError), err:
sys.exit('ERROR: unable to overwrite current version')
- downloader.to_screen('Updated to version %s' % latest_version)
+ downloader.to_screen('Updated youtube-dl. Restart to use the new version.')
def parseOpts():
# Deferred imports