diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2012-12-11 07:52:44 -0800 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2012-12-11 07:52:44 -0800 |
commit | d050de77f94a5dc9071c0b459ba62cb09c6696c4 (patch) | |
tree | 3bea4b6975544ef76241ccf402de541da350b4ac /devscripts/transition_helper.py | |
parent | 4fb1acc212555e3e817f858dce964876eef75d85 (diff) | |
parent | 95eb771dcda47f948b050da85c7ff22539e3ee12 (diff) |
Merge pull request #580 from FiloSottile/master
The new shiny build system
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') |