]> Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/gh-pages/add-version.py
116420ef2f0e4561a07ce558590088b418872179
[youtubedl] / devscripts / gh-pages / add-version.py
1 #!/usr/bin/env python3
2
3 import json
4 import sys
5 import hashlib
6 import urllib.request
7
8 if len(sys.argv) <= 1:
9 print('Specify the version number as parameter')
10 sys.exit()
11 version = sys.argv[1]
12
13 with open('update/LATEST_VERSION', 'w') as f:
14 f.write(version)
15
16 versions_info = json.load(open('update/versions.json'))
17 if 'signature' in versions_info:
18 del versions_info['signature']
19
20 new_version = {}
21
22 filenames = {
23 'bin': 'youtube-dl',
24 'exe': 'youtube-dl.exe',
25 'tar': 'youtube-dl-%s.tar.gz' % version}
26 for key, filename in filenames.items():
27 print('Downloading and checksumming %s...' % filename)
28 url = 'https://yt-dl.org/downloads/%s/%s' % (version, filename)
29 data = urllib.request.urlopen(url).read()
30 sha256sum = hashlib.sha256(data).hexdigest()
31 new_version[key] = (url, sha256sum)
32
33 versions_info['versions'][version] = new_version
34 versions_info['latest'] = version
35
36 with open('update/versions.json', 'w') as jsonf:
37 json.dump(versions_info, jsonf, indent=4, sort_keys=True)