]> Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/gh-pages/generate-download.py
392e3ba21ab86070f2df164362fbd177b750c726
[youtubedl] / devscripts / gh-pages / generate-download.py
1 #!/usr/bin/env python3
2 from __future__ import unicode_literals
3
4 import hashlib
5 import urllib.request
6 import json
7
8 versions_info = json.load(open('update/versions.json'))
9 version = versions_info['latest']
10 URL = versions_info['versions'][version]['bin'][0]
11
12 data = urllib.request.urlopen(URL).read()
13
14 # Read template page
15 with open('download.html.in', 'r', encoding='utf-8') as tmplf:
16 template = tmplf.read()
17
18 md5sum = hashlib.md5(data).hexdigest()
19 sha1sum = hashlib.sha1(data).hexdigest()
20 sha256sum = hashlib.sha256(data).hexdigest()
21 template = template.replace('@PROGRAM_VERSION@', version)
22 template = template.replace('@PROGRAM_URL@', URL)
23 template = template.replace('@PROGRAM_MD5SUM@', md5sum)
24 template = template.replace('@PROGRAM_SHA1SUM@', sha1sum)
25 template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
26 template = template.replace('@EXE_URL@', versions_info['versions'][version]['exe'][0])
27 template = template.replace('@EXE_SHA256SUM@', versions_info['versions'][version]['exe'][1])
28 template = template.replace('@TAR_URL@', versions_info['versions'][version]['tar'][0])
29 template = template.replace('@TAR_SHA256SUM@', versions_info['versions'][version]['tar'][1])
30 with open('download.html', 'w', encoding='utf-8') as dlf:
31 dlf.write(template)