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