]> git.bitcoin.ninja Git - youtube-dl/blob - devscripts/gh-pages/generate-download.py
[goldenmoustache] Remove extractor (Closes #10298)
[youtube-dl] / 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 sha256sum = hashlib.sha256(data).hexdigest()
19 template = template.replace('@PROGRAM_VERSION@', version)
20 template = template.replace('@PROGRAM_URL@', URL)
21 template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
22 template = template.replace('@EXE_URL@', versions_info['versions'][version]['exe'][0])
23 template = template.replace('@EXE_SHA256SUM@', versions_info['versions'][version]['exe'][1])
24 template = template.replace('@TAR_URL@', versions_info['versions'][version]['tar'][0])
25 template = template.replace('@TAR_SHA256SUM@', versions_info['versions'][version]['tar'][1])
26 with open('download.html', 'w', encoding='utf-8') as dlf:
27     dlf.write(template)