8 URL = 'https://github.com/downloads/rg3/youtube-dl/youtube-dl'
10 with tempfile.NamedTemporaryFile(suffix='youtube-dl', delete=True) as ytdl_file:
11 with urllib.request.urlopen(URL) as dl:
12 shutil.copyfileobj(dl, ytdl_file)
15 data = ytdl_file.read()
18 version = subprocess.check_output(['python3', ytdl_file.name, '--version']).decode('ascii').strip()
21 with open('download.html.in', 'r', encoding='utf-8') as tmplf:
22 template = tmplf.read()
24 md5sum = hashlib.md5(data).hexdigest()
25 sha1sum = hashlib.sha1(data).hexdigest()
26 sha256sum = hashlib.sha256(data).hexdigest()
27 template = template.replace('@PROGRAM_VERSION@', version)
28 template = template.replace('@PROGRAM_URL@', URL)
29 template = template.replace('@PROGRAM_MD5SUM@', md5sum)
30 template = template.replace('@PROGRAM_SHA1SUM@', sha1sum)
31 template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
32 with open('download.html', 'w', encoding='utf-8') as dlf: