6 sys.stderr.write(u'Hi! We changed distribution method and now youtube-dl needs to update itself one more time.\n')
7 sys.stderr.write(u'This will only happen once. Simply press enter to go on. Sorry for the trouble!\n')
8 sys.stderr.write(u'The new location of the binaries is https://github.com/rg3/youtube-dl/downloads, not the git repository.\n\n')
12 filename = sys.argv[0]
14 API_URL = "https://api.github.com/repos/rg3/youtube-dl/downloads"
15 EXE_URL = "https://github.com/downloads/rg3/youtube-dl/youtube-dl.exe"
17 if not os.access(filename, os.W_OK):
18 sys.exit('ERROR: no write permissions on %s' % filename)
20 exe = os.path.abspath(filename)
21 directory = os.path.dirname(exe)
22 if not os.access(directory, os.W_OK):
23 sys.exit('ERROR: no write permissions on %s' % directory)
26 urlh = urllib2.urlopen(EXE_URL)
27 newcontent = urlh.read()
29 with open(exe + '.new', 'wb') as outf:
30 outf.write(newcontent)
31 except (IOError, OSError) as err:
32 sys.exit('ERROR: unable to download latest version')
35 bat = os.path.join(directory, 'youtube-dl-updater.bat')
38 echo Updating youtube-dl...
39 ping 127.0.0.1 -n 5 -w 1000 > NUL
42 \n""" %(exe, exe, bat))
46 except (IOError, OSError) as err:
47 sys.exit('ERROR: unable to overwrite current version')
49 sys.stderr.write(u'Done! Now you can run youtube-dl.\n')