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.

42 lines
1.1 KiB

11 years ago
11 years ago
  1. #!/usr/bin/env python3
  2. import json
  3. import sys
  4. import hashlib
  5. import os.path
  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 = {
  17. 'bin': 'youtube-dl',
  18. 'exe': 'youtube-dl.exe',
  19. 'tar': 'youtube-dl-%s.tar.gz' % version}
  20. build_dir = os.path.join('..', '..', 'build', version)
  21. for key, filename in filenames.items():
  22. url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
  23. fn = os.path.join(build_dir, filename)
  24. with open(fn, 'rb') as f:
  25. data = f.read()
  26. if not data:
  27. raise ValueError('File %s is empty!' % fn)
  28. sha256sum = hashlib.sha256(data).hexdigest()
  29. new_version[key] = (url, sha256sum)
  30. versions_info['versions'][version] = new_version
  31. versions_info['latest'] = version
  32. with open('update/versions.json', 'w') as jsonf:
  33. json.dump(versions_info, jsonf, indent=4, sort_keys=True)