moved docs and updates generation scripts from gh-pages branch to devscripts

rtmp_test
Filippo Valsorda 11 years ago
parent 8cad53e84c
commit 067f6a3536

@ -0,0 +1,33 @@
#!/usr/bin/env python3
import hashlib
import shutil
import subprocess
import tempfile
import urllib.request
URL = 'https://github.com/downloads/rg3/youtube-dl/youtube-dl'
with tempfile.NamedTemporaryFile(suffix='youtube-dl', delete=True) as ytdl_file:
with urllib.request.urlopen(URL) as dl:
shutil.copyfileobj(dl, ytdl_file)
ytdl_file.seek(0)
data = ytdl_file.read()
ytdl_file.flush()
version = subprocess.check_output(['python3', ytdl_file.name, '--version']).decode('ascii').strip()
# Read template page
with open('download.html.in', 'r', encoding='utf-8') as tmplf:
template = tmplf.read()
md5sum = hashlib.md5(data).hexdigest()
sha1sum = hashlib.sha1(data).hexdigest()
sha256sum = hashlib.sha256(data).hexdigest()
template = template.replace('@PROGRAM_VERSION@', version)
template = template.replace('@PROGRAM_URL@', URL)
template = template.replace('@PROGRAM_MD5SUM@', md5sum)
template = template.replace('@PROGRAM_SHA1SUM@', sha1sum)
template = template.replace('@PROGRAM_SHA256SUM@', sha256sum)
with open('download.html', 'w', encoding='utf-8') as dlf:
dlf.write(template)

@ -0,0 +1,30 @@
#! /usr/bin/env python3
import rsa
import json
from binascii import hexlify
# TODO path discovery
versions_info = json.load(open('update/versions.json'))
if 'signature' in versions_info:
del versions_info['signature']
print('Enter the PKCS1 private key, followed by a blank line:')
privkey = ''
while True:
try:
line = input()
except EOFError:
break
if line == '':
break
privkey += line + '\n'
privkey = bytes(privkey, 'ascii')
privkey = rsa.PrivateKey.load_pkcs1(privkey)
signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode()
print('signature: ' + signature)
versions_info['signature'] = signature
json.dump(versions_info, open('update/versions.json', 'w'), indent=4, sort_keys=True)

@ -0,0 +1,21 @@
#!/usr/bin/env python
# coding: utf-8
from __future__ import with_statement
import datetime
import glob
import io # For Python 2 compatibilty
import os
import re
year = str(datetime.datetime.now().year)
for fn in glob.glob('*.html*'):
with io.open(fn, encoding='utf-8') as f:
content = f.read()
newc = re.sub(u'(?P<copyright>Copyright © 2006-)(?P<year>[0-9]{4})', u'Copyright © 2006-' + year, content)
if content != newc:
tmpFn = fn + '.part'
with io.open(tmpFn, 'wt', encoding='utf-8') as outf:
outf.write(newc)
os.rename(tmpFn, fn)
Loading…
Cancel
Save