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