mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-11-05 09:57:59 +09:00
Update update mechanism (Closes #4)
This commit is contained in:
parent
36cf7bccde
commit
d207e7cf88
@ -1 +0,0 @@
|
|||||||
2011.08.04
|
|
23
youtube-dl
23
youtube-dl
@ -15,6 +15,8 @@ __author__ = (
|
|||||||
__license__ = 'Public Domain'
|
__license__ = 'Public Domain'
|
||||||
__version__ = '2011.08.28-phihag'
|
__version__ = '2011.08.28-phihag'
|
||||||
|
|
||||||
|
UPDATE_URL = 'https://raw.github.com/phihag/youtube-dl/master/youtube-dl'
|
||||||
|
|
||||||
import cookielib
|
import cookielib
|
||||||
import datetime
|
import datetime
|
||||||
import gzip
|
import gzip
|
||||||
@ -3071,24 +3073,27 @@ def updateSelf(downloader, filename):
|
|||||||
if not os.access(filename, os.W_OK):
|
if not os.access(filename, os.W_OK):
|
||||||
sys.exit('ERROR: no write permissions on %s' % filename)
|
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:
|
try:
|
||||||
latest_url = 'http://github.com/rg3/youtube-dl/raw/master/LATEST_VERSION'
|
try:
|
||||||
latest_version = urllib.urlopen(latest_url).read().strip()
|
urlh = urllib.urlopen(UPDATE_URL)
|
||||||
prog_url = 'http://github.com/rg3/youtube-dl/raw/%s/youtube-dl' % latest_version
|
newcontent = urlh.read()
|
||||||
newcontent = urllib.urlopen(prog_url).read()
|
finally:
|
||||||
|
urlh.close()
|
||||||
except (IOError, OSError), err:
|
except (IOError, OSError), err:
|
||||||
sys.exit('ERROR: unable to download latest version')
|
sys.exit('ERROR: unable to download latest version')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stream = open(filename, 'wb')
|
outf = open(filename, 'wb')
|
||||||
stream.write(newcontent)
|
try:
|
||||||
stream.close()
|
outf.write(newcontent)
|
||||||
|
finally:
|
||||||
|
outf.close()
|
||||||
except (IOError, OSError), err:
|
except (IOError, OSError), err:
|
||||||
sys.exit('ERROR: unable to overwrite current version')
|
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():
|
def parseOpts():
|
||||||
# Deferred imports
|
# Deferred imports
|
||||||
|
Loading…
Reference in New Issue
Block a user