diff options
author | Jeff Crouse <jefftimesten@gmail.com> | 2013-01-05 15:03:54 -0500 |
---|---|---|
committer | Jeff Crouse <jefftimesten@gmail.com> | 2013-01-05 15:03:54 -0500 |
commit | 258d5850c91e0d37a36c6bae0a25314f8149b05a (patch) | |
tree | 7d87df8436a588a4338a460499d8614006b6254a /devscripts/transition_helper.py | |
parent | 187da2c093ad1013ea714a464e615de9aa773482 (diff) | |
parent | 8e5f7618704805caf9fac093e604834237a7965c (diff) |
Merge branch 'master' of https://github.com/rg3/youtube-dl
Conflicts:
.gitignore
LATEST_VERSION
Makefile
youtube-dl
youtube-dl.exe
youtube_dl/InfoExtractors.py
youtube_dl/__init__.py
Diffstat (limited to 'devscripts/transition_helper.py')
-rw-r--r-- | devscripts/transition_helper.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/devscripts/transition_helper.py b/devscripts/transition_helper.py new file mode 100644 index 000000000..d5ca2d4ba --- /dev/null +++ b/devscripts/transition_helper.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +import sys, os + +try: + import urllib.request as compat_urllib_request +except ImportError: # Python 2 + import urllib2 as compat_urllib_request + +sys.stderr.write(u'Hi! We changed distribution method and now youtube-dl needs to update itself one more time.\n') +sys.stderr.write(u'This will only happen once. Simply press enter to go on. Sorry for the trouble!\n') +sys.stderr.write(u'The new location of the binaries is https://github.com/rg3/youtube-dl/downloads, not the git repository.\n\n') + +try: + raw_input() +except NameError: # Python 3 + input() + +filename = sys.argv[0] + +API_URL = "https://api.github.com/repos/rg3/youtube-dl/downloads" +BIN_URL = "https://github.com/downloads/rg3/youtube-dl/youtube-dl" + +if not os.access(filename, os.W_OK): + sys.exit('ERROR: no write permissions on %s' % filename) + +try: + urlh = compat_urllib_request.urlopen(BIN_URL) + newcontent = urlh.read() + urlh.close() +except (IOError, OSError) as err: + sys.exit('ERROR: unable to download latest version') + +try: + with open(filename, 'wb') as outf: + outf.write(newcontent) +except (IOError, OSError) as err: + sys.exit('ERROR: unable to overwrite current version') + +sys.stderr.write(u'Done! Now you can run youtube-dl.\n') |