logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

add-version.py (1363B)


  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. dirn = os.path.dirname
  8. sys.path.insert(0, dirn(dirn(dirn(os.path.abspath(__file__)))))
  9. from devscripts.utils import read_file, write_file
  10. from youtube_dl.compat import compat_open as open
  11. if len(sys.argv) <= 1:
  12. print('Specify the version number as parameter')
  13. sys.exit()
  14. version = sys.argv[1]
  15. write_file('update/LATEST_VERSION', version)
  16. versions_info = json.loads(read_file('update/versions.json'))
  17. if 'signature' in versions_info:
  18. del versions_info['signature']
  19. new_version = {}
  20. filenames = {
  21. 'bin': 'youtube-dl',
  22. 'exe': 'youtube-dl.exe',
  23. 'tar': 'youtube-dl-%s.tar.gz' % version}
  24. build_dir = os.path.join('..', '..', 'build', version)
  25. for key, filename in filenames.items():
  26. url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
  27. fn = os.path.join(build_dir, filename)
  28. with open(fn, 'rb') as f:
  29. data = f.read()
  30. if not data:
  31. raise ValueError('File %s is empty!' % fn)
  32. sha256sum = hashlib.sha256(data).hexdigest()
  33. new_version[key] = (url, sha256sum)
  34. versions_info['versions'][version] = new_version
  35. versions_info['latest'] = version
  36. with open('update/versions.json', 'w', encoding='utf-8') as jsonf:
  37. json.dumps(versions_info, jsonf, indent=4, sort_keys=True)