You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
958 B

  1. #!/usr/bin/env python3
  2. import json
  3. import sys
  4. import hashlib
  5. import urllib.request
  6. if len(sys.argv) <= 1:
  7. print('Specify the version number as parameter')
  8. sys.exit()
  9. version = sys.argv[1]
  10. with open('update/LATEST_VERSION', 'w') as f:
  11. f.write(version)
  12. versions_info = json.load(open('update/versions.json'))
  13. if 'signature' in versions_info:
  14. del versions_info['signature']
  15. new_version = {}
  16. filenames = {'bin': 'youtube-dl', 'exe': 'youtube-dl.exe', 'tar': 'youtube-dl-%s.tar.gz' % version}
  17. for key, filename in filenames.items():
  18. print('Downloading and checksumming %s...' %filename)
  19. url = 'http://youtube-dl.org/downloads/%s/%s' % (version, filename)
  20. data = urllib.request.urlopen(url).read()
  21. sha256sum = hashlib.sha256(data).hexdigest()
  22. new_version[key] = (url, sha256sum)
  23. versions_info['versions'][version] = new_version
  24. versions_info['latest'] = version
  25. json.dump(versions_info, open('update/versions.json', 'w'), indent=4, sort_keys=True)