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.

37 lines
1021 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 = {
  17. 'bin': 'youtube-dl',
  18. 'exe': 'youtube-dl.exe',
  19. 'tar': 'youtube-dl-%s.tar.gz' % version}
  20. for key, filename in filenames.items():
  21. print('Downloading and checksumming %s...' % filename)
  22. url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
  23. data = urllib.request.urlopen(url).read()
  24. sha256sum = hashlib.sha256(data).hexdigest()
  25. new_version[key] = (url, sha256sum)
  26. versions_info['versions'][version] = new_version
  27. versions_info['latest'] = version
  28. with open('update/versions.json', 'w') as jsonf:
  29. json.dump(versions_info, jsonf, indent=4, sort_keys=True)