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.

43 lines
1.1 KiB

11 years ago
11 years ago
  1. #!/usr/bin/env python3
  2. from __future__ import unicode_literals
  3. import json
  4. import sys
  5. import hashlib
  6. import os.path
  7. if len(sys.argv) <= 1:
  8. print('Specify the version number as parameter')
  9. sys.exit()
  10. version = sys.argv[1]
  11. with open('update/LATEST_VERSION', 'w') as f:
  12. f.write(version)
  13. versions_info = json.load(open('update/versions.json'))
  14. if 'signature' in versions_info:
  15. del versions_info['signature']
  16. new_version = {}
  17. filenames = {
  18. 'bin': 'youtube-dl',
  19. 'exe': 'youtube-dl.exe',
  20. 'tar': 'youtube-dl-%s.tar.gz' % version}
  21. build_dir = os.path.join('..', '..', 'build', version)
  22. for key, filename in filenames.items():
  23. url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
  24. fn = os.path.join(build_dir, filename)
  25. with open(fn, 'rb') as f:
  26. data = f.read()
  27. if not data:
  28. raise ValueError('File %s is empty!' % fn)
  29. sha256sum = hashlib.sha256(data).hexdigest()
  30. new_version[key] = (url, sha256sum)
  31. versions_info['versions'][version] = new_version
  32. versions_info['latest'] = version
  33. with open('update/versions.json', 'w') as jsonf:
  34. json.dump(versions_info, jsonf, indent=4, sort_keys=True)