From: Filippo Valsorda Date: Sun, 30 Dec 2012 20:02:19 +0000 (+0100) Subject: moved docs and updates generation scripts from gh-pages branch to devscripts X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=067f6a3536cfd8338c1d17400128d5cec405bce7;p=youtube-dl moved docs and updates generation scripts from gh-pages branch to devscripts --- diff --git a/devscripts/gh-pages/generate-download.py b/devscripts/gh-pages/generate-download.py new file mode 100755 index 000000000..f19729f59 --- /dev/null +++ b/devscripts/gh-pages/generate-download.py @@ -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) diff --git a/devscripts/gh-pages/sign_versions.py b/devscripts/gh-pages/sign_versions.py new file mode 100755 index 000000000..5d94a3a03 --- /dev/null +++ b/devscripts/gh-pages/sign_versions.py @@ -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) \ No newline at end of file diff --git a/devscripts/gh-pages/update-copyright.py b/devscripts/gh-pages/update-copyright.py new file mode 100755 index 000000000..12c2a9194 --- /dev/null +++ b/devscripts/gh-pages/update-copyright.py @@ -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'(?PCopyright © 2006-)(?P[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)